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

Local variables (even if designated as xdata) are in code space

Example:
void kfunc(unsigned char * m)
{ unsigned char xdata * k;

REG = *k;
}

If I hover over k, UVision says k = C:0x0000. If I define k as a global no such issues.

Am I missing something here?

Parents
  • I didn't post the actual code, which does initialize the pointer. I still don't know why the compiler would place the location of the actual pointer variable (NOT the target) in code space. As I've mentioned, using a global produces the correct behavior while a local does not. Here is, essentially, the actual code:

    #define BASE 0x1000

    void blah (unsigned char Offset)
    { unsigned char xdata *Address; Address = (BASE + Offset);

    DATA1 = *(Address+3); DATA2 = *(Address+2); DATA3 = *(Address+1);
    }

Reply
  • I didn't post the actual code, which does initialize the pointer. I still don't know why the compiler would place the location of the actual pointer variable (NOT the target) in code space. As I've mentioned, using a global produces the correct behavior while a local does not. Here is, essentially, the actual code:

    #define BASE 0x1000

    void blah (unsigned char Offset)
    { unsigned char xdata *Address; Address = (BASE + Offset);

    DATA1 = *(Address+3); DATA2 = *(Address+2); DATA3 = *(Address+1);
    }

Children