📄 pop.htm
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>80386 Programmer's Reference Manual -- Opcode POP</TITLE></HEAD><BODY><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="OUTS.htm"> OUTS/OUTSB/OUTSW/OUTSD Output String to Port</A><BR><B>next:</B><A HREF="POPA.htm"> POPA/POPAD Pop all General Registers</A><P><HR><P><H1>POP -- Pop a Word from the Stack</H1><PRE>Opcode Instruction Clocks Description8F /0 POP m16 5 Pop top of stack into memory word8F /0 POP m32 5 Pop top of stack into memory dword58 + rw POP r16 4 Pop top of stack into word register58 + rd POP r32 4 Pop top of stack into dword register1F POP DS 7,pm=21 Pop top of stack into DS07 POP ES 7,pm=21 Pop top of stack into ES17 POP SS 7,pm=21 Pop top of stack into SS0F A1 POP FS 7,pm=21 Pop top of stack into FS0F A9 POP GS 7,pm=21 Pop top of stack into GS</PRE><H2>Operation</H2><PRE>IF StackAddrSize = 16THEN IF OperandSize = 16 THEN DEST := (SS:SP); (* copy a word *) SP := SP + 2; ELSE (* OperandSize = 32 *) DEST := (SS:SP); (* copy a dword *) SP := SP + 4; FI;ELSE (* StackAddrSize = 32 * ) IF OperandSize = 16 THEN DEST := (SS:ESP); (* copy a word *) ESP := ESP + 2; ELSE (* OperandSize = 32 *) DEST := (SS:ESP); (* copy a dword *) ESP := ESP + 4; FI;FI;</PRE><H2>Description</H2>POP replaces the previous contents of the memory, the register, or thesegment register operand with the word on the top of the 80386 stack,addressed by SS:SP (address-size attribute of 16 bits) or SS:ESP(addresssize attribute of 32 bits). The stack pointer SP is incrementedby 2 for an operand-size of 16 bits or by 4 for an operand-size of 32 bits.It then points to the new top of stack.<P>POP CS is not an 80386 instruction. Popping from the stack into the CSregister is accomplished with a <A HREF="RET.htm">RET</A> instruction.<P>If the destination operand is a segment register (DS, ES, FS, GS, orSS), the value popped must be a selector. In protected mode, loading theselector initiates automatic loading of the descriptor informationassociated with that selector into the hidden part of the segment register;loading also initiates validation of both the selector and the descriptorinformation.<P>A null value (0000-0003) may be popped into the DS, ES, FS, or GSregister without causing a protection exception. An attempt to referencea segment whose corresponding segment register is loaded with a nullvalue causes a #GP(0) exception. No memory reference occurs. The savedvalue of the segment register is null.<P>A POP SS instruction inhibits all interrupts, including NMI, until afterexecution of the next instruction. This allows sequential execution of POPSS and POP eSP instructions without danger of having an invalid stackduring an interrupt. However, use of the <A HREF="LGS.htm">LSS</A> instruction is the preferredmethod of loading the SS and eSP registers.<P>Loading a segment register while in protected mode results in specialchecks and actions, as described in the following listing:<PRE>IF SS is loaded: IF selector is null THEN #GP(0); Selector index must be within its descriptor table limits ELSE #GP(selector); Selector's RPL must equal CPL ELSE #GP(selector); AR byte must indicate a writable data segment ELSE #GP(selector); DPL in the AR byte must equal CPL ELSE #GP(selector); Segment must be marked present ELSE #SS(selector); Load SS register with selector; Load SS register with descriptor;IF DS, ES, FS or GS is loaded with non-null selector: AR byte must indicate data or readable code segment ELSE #GP(selector); IF data or nonconforming code THEN both the RPL and the CPL must be less than or equal to DPL in AR byte ELSE #GP(selector); FI; Segment must be marked present ELSE #NP(selector); Load segment register with selector; Load segment register with descriptor;IF DS, ES, FS, or GS is loaded with a null selector: Load segment register with selector Clear valid bit in invisible portion of register</PRE><H2>Flags Affected</H2>None<H2>Protected Mode Exceptions</H2>#GP, #SS, and #NP if a segment register is being loaded; #SS(0) if thecurrent top of stack is not within the stack segment; #GP(0) if the resultis in a nonwritable segment; #GP(0) for an illegal memory operandeffective address in the CS, DS, ES, FS, or GS segments; #SS(0) for anillegal address in the SS segment; #PF(fault-code) for a page fault<H2>Real Address Mode Exceptions</H2>Interrupt 13 if any part of the operand would lie outside of the effectiveaddress space from 0 to 0FFFFH<H2>Virtual 8086 Mode Exceptions</H2>Same exceptions as in real-address mode; #PF(fault-code) for a pagefault<P><HR><P><B>up:</B> <A HREF="c17.htm">Chapter 17 -- 80386 Instruction Set</A><BR><B>prev:</B><A HREF="OUTS.htm"> OUTS/OUTSB/OUTSW/OUTSD Output String to Port</A><BR><B>next:</B><A HREF="POPA.htm"> POPA/POPAD Pop all General Registers</A></BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -