Code sample:
volatile __sbit __at 0xE9 RFCON_SB_RFCSN;
volatile __sfr __at 0xE7 SPIRDAT;
void foo(char bar){
//RFCON_SB_RFCSN = 0;
__asm clr _RFCON_SB_RFCSN __endasm;
SPIRDAT = bar;
}
void main(){
__asm clr _RFCON_SB_RFCSN __endasm;
SPIRDAT = 123;
}
Tested with 3.3.0 #8604 (Dec 30 2013) (Linux) and 3.4.1 #8986 (Apr 12 2014) (Linux)
Compiled code (sdcc main.c):
_foo:
mov _SPIRDAT,dpl
clr _RFCON_SB_RFCSN
ret
Expected asm:
_foo:
clr _RFCON_SB_RFCSN
mov _SPIRDAT,dpl
ret
Does it also happen if you don't use __asm / __endasm but just clear the bit from C with RFCON_SB_RFCSN = 0 ?
Last edit: Maarten Brock 2014-04-13
Reordering only happens when __asm is used.
With "RFCON_SB_RFCSN = 0" operation order is correct.
Fixed in revision #9158.
Philipp