From: Sharwan on
Hi,
I am a newbie learning assembly language. Somewhere I found that
while initialization of global/text segment in program some authors
do it like as shown below :

enter 0,0 ; setup routine
pusha


and while exiting
popa
mov eax, 0
leave

I am not able to understand why we enter 0,0 to stack .
Any help in clarifying this doubt would be much appreciated.

Best Regards
Sharwan
From: Frank Kotler on
Sharwan wrote:
> Hi,
> I am a newbie learning assembly language. Somewhere I found that
> while initialization of global/text segment in program some authors
> do it like as shown below :
>
> enter 0,0 ; setup routine
> pusha
>
>
> and while exiting
> popa
> mov eax, 0
> leave
>
> I am not able to understand why we enter 0,0 to stack .
> Any help in clarifying this doubt would be much appreciated.

Shorter than the explicit instructions. At one time (dunno if it's still
true), "enter" was shorter, but slower, than the explicit instructions,
but "leave" was shorter and equally fast... so you'd sometimes see:

push ebp
mov ebp, esp
sub esp, ???
....
leave
ret

Mmmmm, y'know... looking at this... "enter" is only shorter if the first
operand is non-zero... I don't know why anybody would use "enter 0, 0".
Good question!

Best,
Frank