Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

SDCC MCS51 ISSUES

Joe
2010-04-08
2013-03-12
  • Joe
    Joe
    2010-04-08

    Hi All,
    I'm an ex-KEIL user and trying my hand at SDCC on a Mac. Started with a simple program (simply toggle P1_7 on an AT89c2051). It did not work. So, I looked at the hex and disassembled it to see if I could figure out what was happening.

    0000            02 00 08      LJMP 0X0008
    0003            75 81 07      MOV  0X81, 0X07
    0006           12 00 68        LCALL 0X0068
    .
    .
    0068            75 82 00       MOV 0X82, 0X00
    006B            22                  RET.
    

    … don't get to the rest of the code

    Mmm, what the …?

    That from

    #include "main.h"
    void main(void){
        while(1){
            P1_7 = !P1_7;//toggle
        }
    }
    

    The only ting in the h file:

    #include </Developer/sdcc/share/sdcc/include/mcs51/AT89X051.h>
    

    SDCC does not indicate any problem.
    The compiler options includes

    -mmc51 --code-loc 0X0000
    

    I'm kinda stumped. I know I'm doing something stupid…..

     
  • Hi makwezane2,

    when exchanging the #include "main.h" against
    #include <at89x051.h> SDCC generates the expected:

       0064                     326 00102$:
                                   327 ;       toggle.c:8: { P1_7 = !P1_7; //toggle
       0064 B2 97               328         cpl     _P1_7
       0066 80 FC               329         sjmp    00102$
    

    here. So I guess you are using a header file with Keil syntax?
    This would cause P1_7 to be considered a nonvolatile variable
    (as this variable then has no side effects it may be optimized)

    Checkout section:
    3.4.1.7 sfr / sfr16 / sfr32 / sbit

    You can use the same header file with SDCC and Keil.
    (search device/include/mcs51 for header files which include compiler.h)

    Note, the header file at89x051.h currently shipped with SDCC
    does not yet make use of compiler.h and thus does not allow
    usage with both SDCC and Keil.

     
  • Joe
    Joe
    2010-04-12

    **Thanks Frief.

    You're a scholar and a gentleman.**