Hi

e.g.

struct1 struct ; size of struct is 2 bytes or not?
x byte ?
y byte ?
struct1 ends

struct2 struct ; size of this is 4 bytes or not?
a byte ?
b byte ?
c struct1 {}
struct2 ends

struct3 struct ; size of this struct is...?
d byte ?
e byte ?
f struct2 8 dup({})
struct3 ends

.data?
x1 struct3 {}

What is the size of this structures and how to take the value of y from struct1? I read a few times Chapter 5 from Randall Hyde Art of Assembly Language but i still don't understand.

thanks
Posted on 2003-06-04 13:18:04 by stanks
Yes the size of the structures is the simple addition of all of it's elements, no more. You can use SIZEOF Struct to get the size at compile time. To obtain a particular element of a structure you can use many different addressing techniques, my personal choice is the following:

STRUCT1 Struct
cbsize DWORD ?
x DWORD ?
y DWORD ?
STRUCT1 Ends

.data
mystruct STRUCT1 <0>

.code
mov mystruct.cbsize,SIZEOF STRUCT1
mov mystruct.y,eax

; or

mov edi,OFFSET mystruct
mov .STRUCT1.y,eax
Posted on 2003-06-04 13:22:48 by donkey
MyStruct STRUCT
x BYTE ?
y WORD ?
SizeMyStruct equ $ ; SizeMyStruct=SIZEOF MyStruct
MyStruct ENDS
Posted on 2003-06-04 15:08:51 by MazeGen