Author Topic: POINT_size  (Read 15455 times)

mcamember

  • Guest
POINT_size
« on: January 12, 2008, 11:02:55 PM »
The MSG struc has an element ".pt" which is declared
as RESB POINT_size.

STRUC MSG
.hwnd RESD 1
.message RESD 1
.wParam RESD 1
.lParam RESD 1
.time RESD 1
.pt RESB POINT_size  <<----------
ENDSTRUC

The POINT struc is defined as two DWORDs. Why are two
DWORDs reserved as Bytes (RESB)?

And doesn't the label "POINT_size" need to be defined?
I can't find it in any of the .def or .inc files.
Thanks in advance
afk

nobody

  • Guest
Re: POINT_size
« Reply #1 on: January 13, 2008, 02:27:56 AM »
Good questions! For any "struc XXXX", Nasm calculates "XXXX_size" and makes it available to us. Since POINT is defined as two dwords, POINT_size is defined as 8 - XXXX_size is in bytes - so "resb POINT_size" reserves enough space for two dwords.

If we wanted to define POINT_size_in_dwords as POINT_size/4, we could "resd POINT_size_in_dwords"... but Nasm gives it to us in bytes.

If you need some memory for an instance of your MSG structure, "resb MSG_size" or "sub esp, MSG_size" will do it, even though you haven't defined MSG_size "visibly". Who says Nasm doesn't do anything "behind your back"? :)

Best,
Frank