Initialization of the code segment

  • Follow


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

0
Reply Sharwan 8/7/2008 8:31:54 AM

Sharwan  <spamtrap@crayne.org> wrote:
>
>   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 :

What do you mean by "initialization of global/text segment"?  The 

>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.

If this is the entry to and exit from a function, then I'd believe this.
"enter 0,0" is the same as:
    push ebp
    mov  ebp, esp
What this does is let "ebp" point to a known, fixed location, regardless of
how much manipulation we do with the stack, so we can find any parameters
that were passed, or any local variables we might have allocated.

However, if this is for a function, then pusha/popa is very expensive
overkill.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

0
Reply Tim 8/9/2008 3:02:19 AM


1 Replies
105 Views

(page loaded in 0.052 seconds)

Similiar Articles:












7/27/2012 4:12:16 PM


Reply: