NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: Dumah on August 22, 2011, 07:09:59 PM
-
Hi.
I'm trying to get used to the preprocessor on NASM and trying to understand the stack managing macros (4.8 of http://www.nasm.us/doc/nasmdoc4.html).
I understand how the %local directive works, but was wondering if I could use it with data sizes other than word, dword etc.
If I defined a data structure with 'struc', could I use it here? I have tried to do so but have come up with errors.
Any suggestions would be welcome.
-
Nasm support of structures is currently sparse. You may wish to think of structures as just an array of bytes with a specific size and field offsets within that array.
You might also be interested in the NASMX package. You can read the announcement here (http://forum.nasm.us/index.php?topic=1226.0). There is a bunch of information available at the NASMX Project forum (http://www.asmcommunity.net/board/index.php?board=77.0).
May help you, or may not...
-
Thanks, I'll give it a look.
With regard to the %local directive, do you know how I would declare a lump of memory (say 20 bytes)?
-
That's just one area where NASMX will help you.
A quick example ( I just now wrote it, thus untested )
proc myfunc
locals
local varA, dword ; reserve one dword - 4 bytes
local varB, byte ; reserve one byte
local varC, byte, 255 ; reserve an array of bytes
endlocals
;
; your code here
;
endproc
hope that helps.
-
Ah...that looks like what I need. I'd better get downloading and reading the manuals...
Many thanks