I'm pretty sure I know the answer to my question, but I like verification.
Say I have an array in xdata:
unsigned char xdata foo[32];
I have a function which accepts a pointer and does stuff with it:
void doSomething(unsigned char *ptr, ...) {}
Now, if I pass a pointer to foo to my function:
doSomething(foo, ...);
will accesses to/from ptr in the function use MOVX or will the whole thing blow up?
Or do I need to be explicit about how I write the doSomething function header:
void doSomething(unsigned char xdata *ptr, ...)
I suppose I could make foo[] a global, but I'm trying to keep this generic.
-a
Either format will work. Pass an xdata pointer to a generic pointer, and the compiler adds the tag byte. Pass a generic to an xdata, and the tag byte gets removed. There are differences between register usage and efficiency which are explained in the manual.
The rules of how the compiler copes with conversions between generic and memory-specific pointers are described in the Manual
View all questions in Keil forum