differences of absolute locations

I want an instance of a structure to be put at a specific address in xdata. What is the difference between these declarations:

#define tSetupPacket (* (tDEVICE_REQUEST xdata *)0xFF00)

tDEVICE_REQUEST xdata tSetupPacket _at_ 0xFF00;
It seems that the second behaves incorrectly.
There is also an opportunity to declare a structure at absolute locaiton by #pragma memory segments (supported by non-Keil C or Keil linker).
What is the best choice?

Parents
  • What is the difference between these declarations:

    #define tSetupPacket (* (tDEVICE_REQUEST xdata *)0xFF00)

    tDEVICE_REQUEST xdata tSetupPacket _at_ 0xFF00;


    Well, the first is not a declaration. It is a macro. There is no symbolic information generated for it and it cannot be referenced by name in a debugger. There is no memory space reserved for the object, so the link could actually place other objects at address 0xFF00.

    The second is an absolute declaration. The object is not initialized (and is filled with 0's according to ANSI specification). Space for the object is reserved and a symbolic name is generated. This variable can be viewed or watched by name in a debugger.

    Jon

Reply
  • What is the difference between these declarations:

    #define tSetupPacket (* (tDEVICE_REQUEST xdata *)0xFF00)

    tDEVICE_REQUEST xdata tSetupPacket _at_ 0xFF00;


    Well, the first is not a declaration. It is a macro. There is no symbolic information generated for it and it cannot be referenced by name in a debugger. There is no memory space reserved for the object, so the link could actually place other objects at address 0xFF00.

    The second is an absolute declaration. The object is not initialized (and is filled with 0's according to ANSI specification). Space for the object is reserved and a symbolic name is generated. This variable can be viewed or watched by name in a debugger.

    Jon

Children
More questions in this forum