Hi,
I'm using uVision 3.33, supplied as part of the Luminary Micro design contest. I've noticed the following problem when trying to right-shift a 16-bit unsigned value.
The code produced is:-
176: unsigned short int16; 177: 178: void testfunc(void) 179: { 0x0000072E BD10 POP {r4,pc} 180: int16 >>= 1; 0x00000730 480A LDR r0,[pc,#40] ; @0x0000075C 0x00000732 8800 LDRH r0,[r0,#0x00] 0x00000734 4909 LDR r1,[pc,#36] ; @0x0000075C 0x00000736 8008 STRH r0,[r1,#0x00] 181: }
.. which does not do a right shift !
If I do a left shift, however, it works:-
176: unsigned short int16; 177: 178: void testfunc(void) 179: { 0x0000072E BD10 POP {r4,pc} 180: int16 <<= 1; 0x00000730 480C LDR r0,[pc,#48] ; @0x00000764 0x00000732 8800 LDRH r0,[r0,#0x00] 0x00000734 F64F71FF MOVW r1,#0xFFFF 0x00000738 EA010040 AND r0,r1,r0,LSL #1 0x0000073C 4909 LDR r1,[pc,#36] ; @0x00000764 0x0000073E 8008 STRH r0,[r1,#0x00] 181: }
.. with the LSL instruction clearly visible.
Is this a known bug in the Keil compiler ?
Thanks,
Pete Baston.