Menu

#2268 Volatile asm reordering

closed-fixed
None
MCS51
5
2015-01-19
2014-04-13
AlexThreeD
No

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

Discussion

  • Maarten Brock

    Maarten Brock - 2014-04-13

    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
  • AlexThreeD

    AlexThreeD - 2014-04-13

    Reordering only happens when __asm is used.
    With "RFCON_SB_RFCSN = 0" operation order is correct.

     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
    • Category: other --> MCS51
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in revision #9158.

    Philipp

     

Log in to post a comment.