Figure 4-10 Stack instructions.

NameMnemonic and FormatDescription
Push onto the stack
PUSH    SRC
(SP)(SP)-2
((SP)+1:(SP))(SRC)
Pop from the stack
POP     DST
(DST)((SP)+1:(SP))
(SP)(SP)+2
Push the flags
PUSHF
(SP)(SP)-2
((SP)+1:(SP))(PSW)
Pop the flags
POPF
(PSW)((SP)+1:(SP))
(SP)(SP)+2

Flags: The flags are affected only by the POPF instruction.

Addressing modes: For the PUSH and POP instructions the operand must be a word and may not be immediate. A segment register can be specified as the operand in a PUSH or POP instruction. However, CS cannot be used in a POP instruction.

Figure 4-15 Call and return instructions.

NameMnemonic and FormatDescription
Intrasegment direct call
CALL    DST
(SP)(SP)-2
((SP)+1:(SP))(IP)
(IP)(IP)+D16*
Intrasegment indirect call
CALL    DST
(SP)(SP)-2
((SP)+1:(SP))(IP)
(IP)(EA)
Intersegment direct call
CALL    DST
(SP)(SP)-2
((SP)+1:(SP))(CS)
(SP)(SP)-2
((SP)+1:(SP))(IP)
(IP)D16
(CS)Segment address (Last word of instruction)
Intersegment indirect call
CALL    DST
(SP)(SP)-2
((SP)+1:(SP))(CS)
(SP)(SP)-2
((SP)+1:(SP))(IP)
(IP)(EA)
(CS)(EA+2)
Intrasegment return
RET
(IP)((SP)+1:(SP))
(SP)(SP)+2
Intrasegment return with immediate data
RET     EXP**
Same as above except, also
(SP)(SP)+D16
Intersegment return
RET
(IP)((SP)+1:(SP))
(SP)(SP)+2
(CS)((SP)+1:(SP))
(SP)(SP)+2
Intersegment return with immediate data
RET     EXP**
Same as above except, also
(SP)(SP)+D16

*Displacement between the destination and the instruction following the CALL instruction.

**EXP is an expression that evaluates to a constant and becomes the D16 portion of the instruction.

Flags: No flags are affected.

Addressing modes: May be any branch addressing mode except a short CALL.

Stack facilities normally involve the use of indirect addressing through a special register, the stack pointer, that is automatically decremented as items are put on the stack and incremented as they are retrieved. Putting something on the stack is called a push and taking it off is called a pop. The address of the last element pushed onto the stack is known as the top of the stack (TOS).

On the 8086, the physical stack address is obtained from both (SP) and (SS) or (BP) and (SS), with SP being the implied stack pointer register for all push and pop operations and SS being the stack segment register. The (SS) are the lowest address in (i.e., limit of) the stack area and may be referred to as the base of the stack. The original contents of the SP are considered to be the largest offset the stack should attain. Therefore, the stack is considered to occupy the memory locations from 16 times (SS) to 16 times (SS) plus the original (SP).


Table of Contents | Next page | Previous page

This is page 58.