The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 29, 2007, 09:22:17 AM

Title: push/pop
Post by: ragdog on November 29, 2007, 09:22:17 AM
hi guys

i have a questions to push/pop
use a subroutine with registers must I  set the registers with push and pop?

example:

subroutine proc
push esi
inc esi
...
...
..

pop esi
ret
subroutine endp


greets
ragdog
Title: Re: push/pop
Post by: Shantanu Gadgil on November 29, 2007, 09:49:42 AM
Quoteuse a subroutine with registers must I  set the registers with push and pop?
"set" ???
Do you mean save ?

Form the sample code ... if you are setting 'esi' before the function is called, at the end of the function it has been reset to the same.

-
Shantanu
Title: Re: push/pop
Post by: ragdog on November 29, 2007, 09:58:25 AM
hi

yes i mean save ::)

i uses esi ebx register in my wndproc and call then the subroutine
if I in the subroutine registers not  save with push then does not work  the routine my ask was if I with register work must I always the registers save with push


sry for my english

greets
ragdog
Title: Re: push/pop
Post by: sonic on November 29, 2007, 10:21:12 AM
esi edi ebx must be preserved otherwise you may encounter errors. Masm offers "uses" keyword which simplifies the preservation. You won't have to worry about the order with which registers needs to be popped.
Just use it like this

YourProc uses esi ebx proc
.
.
.
YourProc endp
Title: Re: push/pop
Post by: ragdog on November 29, 2007, 10:37:26 AM
thanks for your reply and info

greets
ragdog