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

char xdata *pointer _at_ postion : absolute illegal specifier

Hi

Why does this declaration not work:
char xdata *pointer _at_ postion;

but this one works:
char xdata array[1] _at_ postion;

Should be theoretically the same, or not?

Thanks Egon

  • I'm sure someone here could give you specific references to manuals, but you should consider how the compiler treats each.

    For simplicity, ignore the '_at' portion.

    char xdata *pointer is allocating space for a pointer, the location of the pointer is at a specific location, but the value of which is variable (i.e., non constant).

    char xdata array[1] is allocating space for a single byte of memory at a specific location (i.e., the location is constant).

    So, clearly, they are not the same.

  • "Should be theoretically the same, or not?"

    even leaving aside the Keil-specific 'xdata' extension, they are not the same at all!

    one is an array; the other is just a pointer.

    Regarding the Keil-specific 'xdata' extension - remember that there are two memory spaces to consider for a pointer:

    1. The memory space where the pointer itself is located;
    2. The memory space to which the pointer points.

    www.keil.com/.../c51_le_memspecificptrs.htm

  • remember that there are two memory spaces to consider for a pointer
    here is my definitions, they should make it clear

                                                // pointer in data in
    #define U8DI  unsigned char   idata * data  // data       idata
    #define U8DX  unsigned char   xdata * data  // data       xdata
    #define U8IX  unsigned char   xdata * idata // idata      xdata
    #define U8XX  unsigned char   xdata * xdata // xdata      xdata
    #define U8IC  unsigned char   code  * idata // idata      code
    #define U8DC  unsigned char   code  * data  // data       code
    #define U8XC  unsigned char   code  * xdata // xdata      code
    #define U8CC  unsigned char   code  * code  // code       code
    

    note; no pointer point to DATA simply because that does not mak sense, there is no overhead from IDATA compared to DATA.

    Erik

  • I really think that the OP needs to appreciate the basic difference before getting involved in the question of memory spaces and any other Keil specifics.

    That is to say, he/she must appreciate that there is a difference between a pointer and an array.

  • My problem is I have to place the pointer at a specific location, hence the _at_ keyword. The pointed address is not the question here!

  • Then try:

    xdata char *pointer _at_ location;
    

    Just tried it here, works as I would expect.

  • "My problem is I have to place the pointer at a specific location"

    What is it, exactly, that compels you to do that?

    If this is not a real requirement, then why make life difficult for yourself?!

  • Your right, too much thinking today, therefore the confusion!!

    Thanks for the link, the conversion of the generic pointer to a memory specific pointer solves the compiler error!

    Thanks for the quick help