Hello!!
I would want how do I represent data structures on MASM32? Which is the respect code??
Thanks!!
Hi Juancaobt, welcome to the forum.
First off, try looking in the masm32 help file that came with the masm package.
Look for STRUCT, and it should explain it to you there.
If you are still having problems come back, and we'll try to help.
rags
Examples from windows.inc, part of MASM32.
POINT STRUCT
x DWORD ?
y DWORD ?
POINT ENDS
NMHDR STRUCT
hwndFrom DWORD ?
idFrom DWORD ?
code DWORD ?
NMHDR ends
NMREBARCHILDSIZE STRUCT
hdr NMHDR <>
uBand DWORD ?
wID DWORD ?
rcChild RECT <>
rcBand RECT <>
NMREBARCHILDSIZE ENDS
To use the POINT struct in a program.
.data
apt POINT <30,50> ; initialize both items
bpt POINT <?,40> ; initialize only the second
cpt POINT <?,?>
dpt POINT <>
.code
mov bpt.x, eax ; copy eax into x item of bpt struct
invoke TextOut,hdc,bpt.x,bpt.y,ADDR AppName,eax
Also some of the tutorials use the structs declared in windows.inc
for example MOUSE.ASM from TUTE07
i prefer to use structure with registers.
...
mov esi,offset bpt
assume esi:ptr POINT
mov [esi].y,eax
...
assume esi:nothing
...
the compiled code is shorter then. (i know it doesnt make much sense in general, but i like it small and beautiful, in general i prefer to use registers...)
Quote from: diablo2oo2 on October 12, 2005, 08:54:34 PM
the compiled code is shorter then.
Not if you include the size of "mov esi, offset bpt"... :wink
Quote from: QvasiModo on October 12, 2005, 10:30:23 PM
Quote from: diablo2oo2 on October 12, 2005, 08:54:34 PM
the compiled code is shorter then.
Not if you include the size of "mov esi, offset bpt"... :wink
lol, of cause it will be shorter when you use the structure a lot and not only one entry like in my example.
Another data structure is the array.
.data
hold dd 64 dup (0) ; an array of 64 dwords initialized with zeros
a related one is the (zero terminated) string
szStr db "ABCDEFGHIJKL",0 ; a 13 byte, 12 characters + 1 zero valued char string
Quote from: diablo2oo2 on October 13, 2005, 07:23:57 PM
lol, of cause it will be shorter when you use the structure a lot and not only one entry like in my example.
I know, just pulling your leg there :bg