THE
80286
INSTRUCTION
SET
ENTER-Make
Stack
Frame
for
Procedure
Parameters
Opcode
C8
dw
00
C8
dw
01
C8
dw
db
Instruction
ENTER
dw,O
ENTER
dW,1
ENTER dW,db
FLAGS
MODIFIED Cc
None
FLAGS
UNDEFINED
None
OPERATION
Clocks
11
15
12+4db
Description
Make stack frame for procedure parameters
Make stack frame
for
procedure parameters
Make stack frame for procedure parameters
ENTER
is
used to create the stack frame required by most block-structured high-level languages. The
first operand specifies
how
many bytes of dynamic storage are to be allocated
on
the stack for the
routine being entered. The second operand gives the lexical nesting level of the routine within the high-
level-language source code.
It
determines
how
many stack frame pointers are copied into the
new
stack
frame from the preceding frame.
BP
is
used as the current stack frame pointer.
If
the second operand
is
0,
ENTER
pushes BP, sets BP to SP, and subtracts the first operand from
SP.
For example, a procedure with
12
bytes of local variables would have an
ENTER
12,0 instruction
at
its entry point and a LEAVE instruction before every RET. The
12
local byteswou!d be addressed as
negative offsets from
[BPj. See also section 4.2.
The formal definition of the
ENTER
instruction for all cases
is
given by the following listing. LEVEL
denotes the value of the second operand.
LEVEL: = LEVEL MOD 32
Push BP
Set a temporary value
FRAM~PTR
: =
sp
If
LEVEL>
0 then
Repeat
(LEVEL
-1)
times:
BP:=
BP - 2
. Push the word pOinted to by
BP
End
repeat
Push
FRAM~PTR
End if
BP:=
FRAME_PTR
SP
: =
SP
- first operand.
B-40