data type bug or not....

I've noticed that the following definitions generate different data
results. Perhaps, I'm overlooking something.

#define TEMP (*(unsigned char xdata *) 0x10F0))

unsigned char xdata sutton2, *sutton;
unsigned char xdata * xdata sutton3;

sutton = &TEMP;
sutton3 = &TEMP;
sutton2 = TEMP;

If XDATA location 0x10F0 has 0x35, then the following compilation
occurs:

'sutton' has the value X:10F0, which is correct.
'sutton2' has the value 0x35, which is correct.
'sutton3' has the value D:10F0, which is not correct.

To complicate things, if I swap the 'sutton2' and 'sutton' declarations to:

unsigned char xdata *sutton, sutton2;

then 'sutton' has the value D:10F0, which is not correct.

There is no DATA location 10F0, therefore garbage is the result.

The source code generated for *sutton being first in the declaration
list is a 2 byte XDATA pointer, which points to the DATA area.

If *sutton is not the first declaration in the list, it is a 3 byte pointer
(which works correctly) that points to XDATA.

Anyone know what the problem is and why the sutton3 declaration
listed above does not force the compiler to generate a pointer that
points to XDATA?

Thanks

Sutton Mehaffey
Lookout Portable Security
sutton@lookoutportablesecurity.com


Parents
  • What exactly are you trying to achieve?

    Have you carefully considered:
    1. the distinction between "Generic" and "memory-specific" pointers;
    2. the Keil syntax for specifying both the location of a pointer, and the memory space which it addresses;
    3. the fact that XDATA memory-specific pointers are 2 bytes, while idata, data, bdata, & pdata memory-specific pointers are one byte;
    4. Generic pointers are always 3 bytes.

    I'm afraid I don't have time to wade through all your layers of multiple indirection, but I suspect that your problem lies in one (or more?) of the above.

Reply
  • What exactly are you trying to achieve?

    Have you carefully considered:
    1. the distinction between "Generic" and "memory-specific" pointers;
    2. the Keil syntax for specifying both the location of a pointer, and the memory space which it addresses;
    3. the fact that XDATA memory-specific pointers are 2 bytes, while idata, data, bdata, & pdata memory-specific pointers are one byte;
    4. Generic pointers are always 3 bytes.

    I'm afraid I don't have time to wade through all your layers of multiple indirection, but I suspect that your problem lies in one (or more?) of the above.

Children
No data
More questions in this forum