#621 SFR wrongly linked on 2.3.5(MCS51) ?


Compiling on 2.3.5(Oct20 2003,Mingw) for mcs51 on
win2000 the code:

sfr TMOD = 0x89;
void com_init (void)
TMOD |= 0x20;
("sdcc.exe bugtest_235.c") generates :

156 ;bugtest_235.c:7: TMOD |= 0x20;
157 ; genOr
0038 43 00 20 158 orl _TMOD,#0x20

but should be (if I compile on 2.3.1):

141 ; bugtest_231.c 7
142 ; genOr
0038 43 89 20 143 orl _TMOD,#0x20
which works. Please note the 00 <->89 for TMOD Addr.

I have seen (in other tests)that many register adresses
are wrongly linked;to numbers i could not follow.

Please let me know what I miss here (as after all testing
I am not sure if my head is still on)
Thanks a lot


  • Erik Petrich

    Erik Petrich - 2003-10-29
    • status: open --> closed
  • Erik Petrich

    Erik Petrich - 2003-10-29

    Logged In: YES

    The problem is your declaration of TMOD. "sfr TMOD = 0x89"
    defines a char sized object at the next available location
    in the sfr address space; the value 0x89 is then stored in
    this object as its initial value. To get your expected
    results, you should instead use "sfr at 0x89 TMOD" which
    defines a char size object at offset 0x89 in the sfr address

    Look in the device/include/8051.h file and sections 3.4.7
    and 3.5 of the SDCC manual for other examples.

  • Erik Petrich

    Erik Petrich - 2003-10-29
    • milestone: --> non_bugs
    • status: closed --> closed-rejected

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks