News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Access Structure Arrays

Started by xroot, August 16, 2007, 04:29:37 PM

Previous topic - Next topic

xroot

Hi,
I am getting this error message A2070: invalid instruction operands

foo Struct
     vName byte 10 dup (?)
     Value byte 50 dup (?)
foo Ends

Main Proc
local info[5]:Foo
            mov eax,K                                         Index of field
            mov ecx,SIZEOF Foo
            mul ecx
            mov info[eax].vName,offset Tmp    <==On this line I get error A2070: invalid instruction operands

What am missing or doing wrong.
Thanks

Jimg

you need to give it a size, eg:
mov dword ptr info[eax].vName,offset Tmp 

however, from the definition in foo, I'm not sure what you wanted to store here, certainly not 10 bytes.
If you wanted to get the actual string from the buffer Tmp into the 10 byte buffer vName, then you have to do a copy of some kind.

evlncrn8

well, if you have to do this then your struct design is wrong

mov info[eax].vName,offset Tmp

should really be...

foo Struct
     vName LPVOID ?
     Value byte 50 dup (?)
foo Ends

and you'd access it like...

mov info.foo.Value, offset Tmp

which should compile quite fine
that way if you change the struct, like adding more to it, or restructuring it it wont break...

really you should design the struct for the purpose you intend to use it for...