NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: afk on March 07, 2012, 05:48:35 PM

Title: MSG and other Windows STRUCs
Post by: afk on March 07, 2012, 05:48:35 PM
Until recently, when writing a Windows app I followed the practice of copying the complete STRUC and all its members into an .INC  file and creating a local label for it :
Code: [Select]
    appmsg:
    istruc MSG
        at MSG.hwnd,               dd    NULL
        at MSG.message,            dd    NULL
        at MSG.wParam,             dd    NULL
        at MSG.lParam,             dd    NULL
        at MSG.time,               dd    NULL
        at MSG.pt,                 dd    NULL
    iend

But I've found that simply defining a variable postpended with  _size works fine and the app appears to be stable (and a lot less cluttered) :

Code: [Select]
appmsg times MSG_size db 0

Is there anything wrong with this shortcut ?
Thanks in advance.
afk
Title: Re: MSG and other Windows STRUCs
Post by: Bryant Keller on March 08, 2012, 12:28:45 AM
Nothing at all wrong with that. In fact, that's what the '_size' equate is defined for. If you create your variables in the .bss section, it looks even cleaner (imho):

Code: [Select]
section .bss
appmsg: resb MSG_size
Title: Re: MSG and other Windows STRUCs
Post by: afk on March 08, 2012, 04:24:32 AM
Hi Bryant,
Thanks again.
afk