NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: david on December 06, 2007, 02:37:07 AM
-
MASM declare loacl variable array and access it like this :
local aa[10]: byte
mov byte ptr aa[0], 16
i want to know how to do it by nasm ?
it seems like need to use %local .
the example in nasm nasm_man:
silly_swap:
%push mycontext ; save the current context
%stacksize small ; tell NASM to use bp
%assign %$localsize 0 ; see text for explanation
%local old_ax:word, old_dx:word
enter %$localsize,0 ; see text for explanation
mov [old_ax],ax ; swap ax & bx
mov [old_dx],dx ; and swap dx & cx
mov ax,bx
mov dx,cx
mov bx,[old_ax]
mov cx,[old_dx]
leave ; restore old bp
ret ;
%pop ; restore original context
i want to know how to declare local variable array ?
-
I'd like to know the same thing =/
Maybe var:dword:dword... ? But I need a 1024 byte local var.
If there's someway to do a data size type like dword, etc..
-
> MASM declare loacl variable array and access it like this :
> local aa[10]: byte
> mov byte ptr aa[0], 16
> i want to know how to do it by nasm ?
> it seems like need to use %local .
Maybe there are other ways but you always can "push" EBP, "mov" EBP,ESP and "sub" the ESP manually so your array will land below EBP ;-)
-
MASM declare loacl variable array and access it like this : LOCAL, that's all. I am not sure you are speaking about MS ASM ?
-
I know this thread is old, but I've noticed people viewing it a lot lately and there never was really a clear answer. To create local variables in a simple manner, I use STRUC's.
SampleProc:
STRUC @SPL
.dwTest RESD 1 ; Local dwTest:DWORD
.arTest RESD 10 ; Local arTest[10]:DWORD
ENDSTRUC
Push Ebp
Mov Ebp, Esp
Sub Esp, @SPL_size
;; Access your locals through [Ebp - 8 - @SPL.dwTest] and [EBP - 8 - @SPL.arTest]
Leave
Ret