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
  • So, have you looked at the generated assembler code?

    A lot of compilers would ignore your pointer variable, and just evaluate the real address for the individual memory accesses - all depending on how good the processor is at doing pointer manipulation.

    In this case, it is porbably as cheap - or cheaper - for the compiler to join (BASE plus a constant offset) in the individual accesses (or as an decremented temp variable) and then add the Offset parameter before making the memory access.

Reply
  • So, have you looked at the generated assembler code?

    A lot of compilers would ignore your pointer variable, and just evaluate the real address for the individual memory accesses - all depending on how good the processor is at doing pointer manipulation.

    In this case, it is porbably as cheap - or cheaper - for the compiler to join (BASE plus a constant offset) in the individual accesses (or as an decremented temp variable) and then add the Offset parameter before making the memory access.

Children
No data