
Instruction Set
4-54
ENTER
ENTER
Operation It Performs
Flag Settings After Instruction
Examples
This example procedure uses ENTER to: push the current frame pointer (BP) onto the
stack, set up BP to point to its stack frame, reserve 4 bytes on the stack for its local variables,
and indicate that it is not called by another procedure.
/* convert level to a number between 0 and 31 */
level = level % 32;
/* save base and frame pointers */
push(BP);
framePointer = SP;
if (
level > 0)
/* reserve storage for each nesting level */
{
for (i = 1;i <
level;i++)
{
BP = BP - 2;
push(BP);
}
push(framePointer);
}
/* update base and frame pointers */
BP = framePointer;
SP = SP -
bytes;
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
–
–
–
–
–
– res – res – res –
; procedure that is not called by another
Main
PROC
FAR
ENTER
4,0
; reserve 4 bytes for variables
; procedure is not called by another
; perform operations
...
; save AX
PUSH
AX
; perform operations
...
LEAVE
; remove variables from stack
RET
2
; remove saved AX from stack
Main
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...