Bit shifting is one of the most frequently used operation in embedded programming. SDCC tries to implement bit-shift operations in the most efficient way possible, e.g.:
unsigned char i;generates the following code:
...
i >>= 4;
...
mov a,_iIn general SDCC will never setup a loop if the shift count is known. Another example:
swap a
anl a,#0x0f
mov _i,a
unsigned int i;will generate:
...
i >>= 9;
...
mov a,(_i + 1)
mov (_i + 1),#0x00
clr c
rrc a
mov _i,a