NASM - The Netwide Assembler
NASM Forum => Example Code => Topic started by: nobody on March 17, 2008, 05:18:00 PM
-
does anybody knows how to push a string on a stack?
eg.
mystr db "1234512345", 0 ; the string (nul terminated)
mov eax, mystr ; the adress of the string is stored in eax
now i need some code to push it on a stack
pls help
-
Well... the most usual thing would be "push mystr" - put the address of the string on the stack. If you really want the string itself on the stack...
mystr db "1234512345", 0
mystr_len equ $ - mystr
...
sub esp, (mystr_len + 3) && -4
mov edi, esp
mov esi, mystr
mov ecx, mystr_len
rep movsb
...
add esp, (mystr_len + 3) && -4
Not much point in copying the string to a "local" variable, usually, but there might be some reason to do so... What do you have in mind?
Best,
Frank
-
i need it so i can print it later to the screen...
i made a sub that prints the string from the stack so i need 1 to put it there
mb a stupid idea
-
Well, it's an "unusual" idea... whether it's "stupid" or not depends on whether it works for whatever you're trying to do!
Does it? If not, what happens?
Best,
Frank