This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

c51: xdata RAM starting at 0x8000 and reentrant

Hello,

Im porting our code to a "8051" harware architecture where the external CODE is placed from 0x0000 to 0x7fff. XDATA RAM is placed from 0x8000 to 0x83ff. I have to use reentrant functions. Program is crashing when entering reentrant functions and having a look into the m51 listing, I realized that local variables ar linked as follows, for instance:

  C:113AH         PUBLIC        _?Sum2EfitoRMS

  -------         PROC          _?SUM2EFITORMS

  x:0021H         SYMBOL        au16Sum2Efi

  -------         DO

  x:0000H         SYMBOL        u32resultado
  x:0004H         SYMBOL        u32auxiliar
  x:0008H         SYMBOL        u32mascara
  x:000CH         SYMBOL        u32auxa

those "RAM" locations seem to access de C:0000 external code area. The architecture is sharing the bus for code and data. Anyway, there's no RAM in those external adresses.

Non-reentrant functions seems to link local variables in the right place:


  -------         PROC          _SCREEN_METER

  X:8027H         SYMBOL        obis
  X:802BH         SYMBOL        valor
  X:802FH         SYMBOL        tarifa

right into the _XDATA_GROUP_

Please a would thank any idea, I don't know exactly the compiler/linker options I have to check to ensure that this linking is correct.

Thanks in advance,

S.

  • those "RAM" locations seem to access de C:0000 external code area.

    No, they're accessing the X:0000 RAM area, exactly as the map file says.

    The architecture is sharing the bus for code and data.

    No, "the architecture" most definitely doesn't do that. Your particular circuit may be wired that way, but that's rather unusual for an 8051 --- why would anyone want to waste address space like that?

    don't know exactly the compiler/linker options I have to check to ensure that this linking is correct.

    You'll have to completely disallow X:0000 .. X:7fff. See your linker settings.

  • Sergio Santos: "The architecture is sharing the bus for code and data."

    Hans-Bernhard Broeker: "No, 'the architecture' most definitely doesn't do that."

    Well, that depends on what precisely you mean by "the architecture" (in quotes) in this case...

    It's described under "8051 Architecture" in the so-called "bible" for the 8051, so I suppose that must give some credance to the statement...

    A standard 8051 chip has only a single external multiplexed addess/data bus - so it has to be shared between code and XDATA:
    /PSEN selects CODE (read-only);
    /RD or /WR selects XDATA (read or write).

  • Hans and Andy, thank you very much for your help,

    well the problem has been solved, but had nothing to do with the question that I posted, sorry.

    The XBPSTACKTOP location was defined out of bounds in Startup, so of course any reentrant function was crashing.

    the "m51" listing is confusing, I mean, I was confused with the lowercase "x:0000" notation and the uppercase "X:0000". The last one mean, yes XDATA, and the location written beside is exactly the address assigned to the variable.
    In the lowercase "x", variables are located also in the XDATA, but withing the stack. The linker doen't know the right location in link-time, doesn't know the top of stack, so that's the result.

    Anyway thank you again for your time

    Regards,

    S.