Initialization of the code segment

This is a discussion on Initialization of the code segment within the ASM x86 ASM 370 forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > ASM x86 ASM 370

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-07-2008, 04:31 AM
Sharwan
Guest
 
Default Initialization of the code segment

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

Reply With Quote
  #2  
Old 08-08-2008, 11:02 PM
Tim Roberts
Guest
 
Default Re: Initialization of the code segment

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.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:58 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.