NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: JoeCoder on July 06, 2011, 08:03:37 AM
-
Hi guys. I understood from one of Frank's examples the way to use structs is something like
struc mystruc
fielda resd 1
fieldb resd 1
endstruc
and then
mov eax,mystruc
mov dword [eax+fielda],fieldc
In the assembler I use for work, we have a way to tell the assembler that a certain gpr should be used as a base address for a structure. It's actually more flexible and complicated than that, but what I want to know is if there is a way to accomplish that feature in NASM.
Edit: I guess the above example is invalid in x86 since you can't "mov" storage to storage, but I don't know how to give a more obvious example and I hope you get the general idea.
I would like to be able to let the assembler know that eax is the base register for mystruc so that I could refer to fields directly and do something like
mov eax,mystruc
; tell the assembler eax is the base address for mystruc
mov dword fielda,fieldc
Is this possible?
Thanks.
-
If I understand you correctly you are asking if the assembler "assumes" certain registers such that they do not have to be specified within the line of code. While x86 does have certain registers that are used implicitly with opcodes you must always specify the base and offsets when accessing your structures. However you are free to write macros that emulate that behavior. That's pretty much how the var() and argv() macros are designed in NASMX which use ebp as the base register. Different purpose but same concept...
-
Thanks, I'll look into those. Sorry for the subject title, I fixed it now.