|
|
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
|
|
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: const reference typedef compile error: - comp.lang.c++.moderated ...... between the word reference and the type reference in your code, let me rewrite the code segment ... > invalid initialization of reference of type > 'value_type&' from ... BIOS/Protected Mode - comp.lang.asm.x86If ANY of the handler code loads a segment register, for instance, it won't work ... taken care of, would it be realistic to load the > option ROM initialization code ... segmentation fault with shared memory - comp.unix.programmer ...hi everybody i ve a pb with this code #include <stdio.h> #include <stdlib.h ... include <sys/shm.h> #define SHM_SIZE 4096 /* make it a 4K shared memory segment ... converting C/Visual BASIC code to MATLAB - comp.soft-sys.matlab ...... possibly different types for each adjacent segment of ... such as arithmetic, etc., similar to initialization ... So instead of re-implementing the C > driver code ... writing robust software? - comp.lang.c++.moderatedOne idea would be more careful coding and code ... for 2+ decades in C++, using > Resource Initialization is ... leaks, nothing - get a bad descriptor or segment leak ... ps/2 mouse w/o int33 - comp.lang.asm.x86Following the BAT completion code (AAh or FCh), the ... Initialization: The PS/2 mouse is normally detected ... EBDA[2] is present then the RomBios enters its segment ... improve strlen - comp.lang.asm.x86... about strlen the result is the same time my code and ... be overall win to just compute the length at initialization. ... Just an example of one market segment. I don't know ... Where did Fortran go? - comp.lang.fortran... lecturers which until today present FORTRAN 77 code ... Still does in the upper segment. >And note the ... has sneaked in. (PARAMETER with non-integer initialization ... problem in interface - comp.lang.fortranSegment faults usually come from either subscripts out ... this is because, this lm_a is from an old code, used ... --- Set up dynamic memory allocation and other initialization ... Automatically Initializing Data Segment Values in MAX-IDE ...The code and data segment facility provided ... loaded into VarA in the code. How, then, is this value initialized? The answer is that the initialization of the data segment ... Data segment - Wikipedia, the free encyclopediaCode segment; Data. The data area ... do not have explicit initialization in source code. For instance a variable declared static int i; would be contained in the BSS segment. 7/27/2012 4:12:16 PM
|
|
|
|
|
|
|
|
|