I stumbled across a code generation problem. I am still using gcc 3.3.0, so maybe this is an old bug. Anyone care to verify this? The problem is in the line "strgtb r2, [r0, #2]": cmp r3, #7 strgtb r2, [r0, #2] ble .L9 In the loop "for (r3=0; r3<8; r3++)" I expected "[r0,#2] = r2, but the condition 'gt' in 'strgtb' only stores the result when r3 > 7. It should be <=7. (Thus strleb r2,[r0.#2] I think) Eric. --------------------- binutils 2.13.2.1 gcc 3.3.0 build under cygwin with options --target=arm-ecos-elf --with-cpu=arm7tdmi --enable-languages=c,c++ --------------------- test.cpp -------- typedef struct { unsigned char data; unsigned char Reserved1; unsigned char control; unsigned char Reserved2; unsigned char tb; unsigned char Reserved3; unsigned short X; } StructMMIO; void test(void) { int lus, lus2; StructMMIO* Mmio = (StructMMIO*)(0xC00000); while(1) for (lus=0; lus<8; lus++) Mmio->control = (1<<lus); } -------------------------------------------------------- arm-ecos-elf-gcc -O2 -S test.cpp The result: test.s ---------------- .file "test.cpp" .text .align 2 .global _Z4testv .type _Z4testv, %function _Z4testv: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. @ lr needed for prologue mov r0, #12582912 mov r1, #1 .L10: mov r3, #0 .L9: mov r2, r1, asl r3 add r3, r3, #1 cmp r3, #7 strgtb r2, [r0, #2] ble .L9 b .L10 .size _Z4testv, .-_Z4testv .ident "GCC: (GNU) 3.3"