THE 80286 INSTRUCTION SET

ENTER-Make Stack Frame for Procedure Parameters

Opcode

 

Instruction

Clocks

Description

C8

dw

00

ENTER dw,O

11

Make stack frame for procedure parameters

C8

dw

01

ENTER dW,1

15

Make stack frame for procedure parameters

C8

dw

db

ENTER dW,db

12+4db

Make stack frame for procedure parameters

FLAGS MODIFIED Cc

None

FLAGS UNDEFINED

None

OPERATION

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

Page 250
Image 250
Intel 80287, 80286 manual ENTER-Make Stack Frame for Procedure Parameters, BP= Frameptr