csc@watmath.UUCP (Computer Sci Club) (12/18/85)
The programmers here at Unit 36 Research have discovered a cute little bug in the DRI C compiler/assembler (for this is probably best considered an assembler bug). If one writes the code a = array[i = 0]; where "i" is an int, the compiler will set up the zero value in a register to perform the array access. In order to do this it writes a "clr a0". The assembler turns this into a "suba.w a0,a0" instruction which will not actually clear the address register. This instruction sign extends the lower word of the address register and then subtracts that value (using 32 bit arithmetic) from the original value. This leaves garbage in the upper 16 bits of the address register. If the compiler then uses that value as a longword: kaboom! It really needs to generate the long version of the instruction. Moving the index initialization out of the subscript cures the problem. We discovered this while writing a memory test program for the wonderful, sexy new .5 megabytes we have installed in the ST. Tracy Tims Brian Stecher PS. Why have none of the damn microcomputer hackers discovered the value of good programming style? I say we shoot anyone who can't write consistent, well structured, visually coherent code. Or just have some licensing scheme to prevent tyros from writing and distributing offensive code 8-). Gack, spew 8-(.