#990 wrong address taken for OED

closed-rejected
nobody
None
5
2013-05-25
2005-09-26
melliw
No

Hi,

I think I found a bug in the SDCC compiler. More
information below (especially point 4).

1. sample code: see attachment

2a.
- if you installed d52 (hex file decompiler), ajust the
makefile so the CFLAGS macro points to the directory
where fx2regs is installed. Then, run: make
2b.
- if you didn't install d52, run: sdcc main.c

3. version: 2.5.3

4. I'm using a Cypress FX2 chip. This chip makes use of
an enhanced 8051 processor. In my c file I included the
line:
OED = 0x3F;
OED is a special function register and it's location is
specified in fx2regs.h:
sfr OED = 0xB5;

I expected a line like:
mov B5h, #3Fh
in the main.d52 file (which means: set 3F to address
B5), but there is no such line.

However, there is a line stating:
mov 28h, #3Fh
which means move 3F to address 28, but this is the
wrong address!!!! I also discovered the following line:
mov 28h, #b5h
So, the right value for OED is stored at location 28h.

It seems to me location 28h should be 'dereferenced'.
Instead of 28h there should stay @28h. However,
according to me, this is not allowed (I thought it was
only allowed for register 0 and 1)

I think the symbol table should take care of the
address of OED. Isn't it possible to take the address
of OED from the symbol table?

I'm very sorry that I cannot locate the exact problem.
I'm not to deep into compiler stuff. I hope you are:P,
and you can help me. Thanks in advance!!!

5. willem_ridderhof@hotmail.com (if you have time to
send me more information I would appreciate that. My
professor will be impressed (and I too) :P)

Regards,
Willem

Discussion

  • melliw
    melliw
    2005-09-26

    .tar.gz file that includes my main.c and fx2regs.h file. Furthermore, my sdcc output

     
    Attachments
  • Maarten Brock
    Maarten Brock
    2005-09-26

    • milestone: --> non_bugs
    • status: open --> closed-rejected
     
  • Maarten Brock
    Maarten Brock
    2005-09-26

    Logged In: YES
    user_id=888171

    RTFM:

    sfr OED = 0xB5;
    OED = 0x3F;

    Now if this was C on any other processor would you expect
    OED to use 0xB5 as the address and 0x3F as a value
    assigned to it? No, I guess not. Then why for SDCC? SDCC !
    = Keil !!!

     
  • Erik Petrich
    Erik Petrich
    2005-09-26

    Logged In: YES
    user_id=635249

    The declaration "sfr OED = 0xB5;" is intended for different
    8051 C compiler. If you'll check the SDCC manual, you will
    find that the declaration that does what you wanted is:

    sfr at 0xB5 OED;