Author Topic: push a string on a stack  (Read 31479 times)

nobody

  • Guest
push a string on a stack
« 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

nobody

  • Guest
Re: push a string on a stack
« Reply #1 on: March 17, 2008, 06:23:24 PM »
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

nobody

  • Guest
Re: push a string on a stack
« Reply #2 on: March 17, 2008, 07:45:03 PM »
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

nobody

  • Guest
Re: push a string on a stack
« Reply #3 on: March 19, 2008, 02:06:11 AM »
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