enter.htm
来自「Programmer s Reference Manual is an impr」· HTM 代码 · 共 109 行
HTM
109 行
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>80386 Programmer's Reference Manual -- Opcode ENTER</TITLE></HEAD><BODY><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="DIV.htm"> DIV Unsigned Divide</A><BR><B>next:</B><A HREF="HLT.htm"> HLT Halt</A><P><HR><P><H1>ENTER -- Make Stack Frame for Procedure Parameters</H1><PRE>Opcode Instruction Clocks DescriptionC8 iw 00 ENTER imm16,0 10 Make procedure stack frameC8 iw 01 ENTER imm16,1 12 Make stack frame for procedure parametersC8 iw ib ENTER imm16,imm8 15+4(n-1) Make stack frame for procedure parameters</PRE><H2>Operation</H2><PRE>level := level MOD 32IF OperandSize = 16 THEN Push(BP) ELSE Push (EBP) FI; (* Save stack pointer *)frame-ptr := eSPIF level > 0THEN (* level is rightmost parameter *) FOR i := 1 TO level - 1 DO IF OperandSize = 16 THEN BP := BP - 2; Push[BP] ELSE (* OperandSize = 32 *) EBP := EBP - 4; Push[EBP]; FI; OD; Push(frame-ptr)FI;IF OperandSize = 16 THEN BP := frame-ptr ELSE EBP := frame-ptr; FI;IF StackAddrSize = 16THEN SP := SP - First operand;ELSE ESP := ESP - ZeroExtend(First operand);FI;</PRE><H2>Description</H2>ENTER creates the stack frame required by most block-structuredhigh-level languages. The first operand specifies the number of bytes ofdynamic storage allocated on the stack for the routine being entered.The second operand gives the lexical nesting level (0 to 31) of the routinewithin the high-level language source code. It determines the number ofstack frame pointers copied into the new stack frame from the precedingframe. BP (or EBP, if the operand-size attribute is 32 bits) is the currentstack frame pointer.<P>If the operand-size attribute is 16 bits, the processor uses BP as theframe pointer and SP as the stack pointer. If the operand-size attribute is32 bits, the processor uses EBP for the frame pointer and ESP for the stackpointer.<P>If the second operand is 0, ENTER pushes the frame pointer (BP orEBP) onto the stack; ENTER then subtracts the first operand from thestack pointer and sets the frame pointer to the current stack-pointervalue.<P>For example, a procedure with 12 bytes of local variables would have anENTER 12,0 instruction at its entry point and a <A HREF="LEAVE.htm">LEAVE</A> instructionbefore every <A HREF="RET.htm">RET</A>. The 12 local bytes would be addressed as negativeoffsets from the frame pointer.<H2>Flags Affected</H2>None<H2>Protected Mode Exceptions</H2>#SS(0) if SP or ESP would exceed the stack limit at any point duringinstruction execution; #PF(fault-code) for a page fault<H2>Real Address Mode Exceptions</H2>None<H2>Virtual 8086 Mode Exceptions</H2>None<P><HR><P><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="DIV.htm"> DIV Unsigned Divide</A><BR><B>next:</B><A HREF="HLT.htm"> HLT Halt</A></BODY>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?