Professional Documents
Culture Documents
Procedures
The Stack
• A one-dimensional data structure.
• Items are added and removed from one end of the
structure.
• Processed in a “last-in, first-out” manner.
• The most recent addition to the stack is called “top
of the stack.”
• A temporary storage area used by both application
programs and the operating system.
PUSH and PUSHF
• Syntax
• PUSH source
– Source is a 16 – bit register or memory word.
• PUSHF
– No operands but pushes the contents of the FLAGS
register onto the stack
PUSH and PUSHF
• Execution of PUSH causes the following to
happen:
• SP is decreased by 2.
• A copy of the source content is moved to the address
specified by SS:SP. The source is unchanged.
POP and POPF
• Syntax
• POP destination
– destination is a 16 – bit register or memory word.
• POPF
– No operands but pops the top of the stack into the FLAGS
register onto the stack
POP and POPF
• Execution of POP causes the following to
happen:
• The content of SS:SP is moved to the destination
• SP is increased by 2.
Application
• Suppose that the stack segment is declared
as follows:
.STACK 100h
ES content
.
.
return_address (offset)