
Instruction Set
4-55
ENTER
ENTER
This example includes two procedures, each of which uses ENTER to create its own stack
frame. Each procedure uses LEAVE to destroy its stack frame before returning to the
procedure that called it.
Tips
Before you use ENTER, use MOV to copy the stack segment to SS and the stack offset to
SP.
If a procedure is not called by another, then use ENTER with a level of 0.
If a procedure is called by another, then use ENTER with a level of 1 for the main procedure,
use ENTER with a level of 2 for the procedure it calls, and so on.
Related Instructions
If you want to
See
Remove the local variables of a procedure from the stack
LEAVE
; top-level procedure
Main
PROC
FAR
ENTER
6,1
; reserve 6 bytes for variables
; level 1 procedure
; perform operations
...
LEAVE
; remove variables from stack
RET
Main
ENDP
; second-level procedure
Sub2
PROC
FAR
ENTER
20,2
; reserve 20 bytes for variables
; level 2 procedure
; perform operations
...
LEAVE
; remove variables from stack
RET
Sub2
ENDP
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...