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

xdata and code segments overlap?

Where is the xdata stored and where is code stored?

The Problem that I am facing is , when I do

unsigned char xdata buff[300];
void func()
{ ...........
.....
..
}

the results of running this application suggests that xdata buff has overwritten the function func.

The Map file shows
the following addresses * * * * * * * X D A T A M E M O R Y ** * * * * * XDATA 0000H 012CH UNIT ?XD?DEMO XDATA 012CH 000AH UNIT _XDATA_GROUP_

* * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE 0003H 00FDH *** GAP *** CODE 0100H 03C7H UNIT ?PR?_FUNC?DEMO CODE 04C7H 0131H UNIT ?C_INITSEG

Which shows the base addresses of XD?DEMO of 300 bytes and the function func to be the same !!!

Also in the code segment, a gap of 256 bytes has been left before the function func.
Hence if the xdata buff size is kept 256 bytes, there is no problem. Only when I exceed this limit , there are problems.

Let me know where is xdata stored and where is the code segment? Are they overlapping?
How can I declare an external data buffer of 300 bytes?

Regards,
Gaurav

Parents
  • OK...
    it is fine if they are relative addresses.
    Just that I am facing a problem when I increase my xdata size to more than 256..and i see that 256 bytes of code is as a gap in the code segment and the function starts from 257th location.
    So I thot maybe the data is corrupting the code when I increase it beyond 256 bytes.
    Thanks a lot for the prompt replies.
    Let me know if you have anything more to tell me that will help me resolve the problem
    Regards,
    Gaurav

Reply
  • OK...
    it is fine if they are relative addresses.
    Just that I am facing a problem when I increase my xdata size to more than 256..and i see that 256 bytes of code is as a gap in the code segment and the function starts from 257th location.
    So I thot maybe the data is corrupting the code when I increase it beyond 256 bytes.
    Thanks a lot for the prompt replies.
    Let me know if you have anything more to tell me that will help me resolve the problem
    Regards,
    Gaurav

Children