Anonymous - 2012-07-27

Hi,

Just started using SDCC, and read in the manual section 8.1.9 about optimization of bit rotations:

unsigned char i; /* unsigned is needed for rotation */
...
i = ((i << 1) | (i >> 7));
...

will generate the following code:

mov a,_i
rl a
mov _i,a

However it doesn't seem to work:

332 ;PeripheralController.c:75: i = ((i>>7) | (i<<1));
   010D FD 21r05s00         333     ld  iy,#_doLeds_i_1_47
   0111 FD 7E 00            334     ld  a,0 (iy)
   0114 07                  335     rlca
   0115 E6 01               336     and a,#0x01
   0117 57                  337     ld  d,a
   0118 FD 7E 00            338     ld  a,0 (iy)
   011B 87                  339     add a, a
   011C B2                  340     or  a, d
   011D FD 77 00            341     ld  0 (iy),a

The variable i is declared as:

    static unsigned char i = 0x11;

Building with command line:

    sdcc -mz80 -c $*.c

Is there an option required to make it work?