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

How to declare a structure?

I define an area of memory that in 'non-volatile' so it doesn't get cleared on powerup. I do this is a module called memmap.asm like this:
MyData DS 512 ;Located at 0x801C

In another module, I want to declare an array of structures starting at the address of MyData. I tried this:
struct tagData
{
BYTE Num1[32];
BYTE Num2[32];
};

struct tagData xdata MyArray[8] _at_ 0x801C

But this doesn't complile. What's wrong?

Thanks for any suggestions,
RickL



  • hello,

    A member of a structure or a parameter may not contain the specification of a
    memory type. The object to which the pointer refers may, however, contain a
    memory type. For example:
    struct vp { char code c; int xdata i; };
    generates error 258.
    struct v1 { char c; int xdata *i; };
    is the correct declaration for the struct.

    a+
    khemaies
    changuel@yahoo.com

  • The reason for this is that the members of a structure must reside in a single contiguous block of memory. If you were to declare a structure with one member residing in CODE, and another member residing in, for example, XDATA, then each instance of the structure would have to be split between the two memory spaces.