SlideShare a Scribd company logo
Microprocessor & assembly language
Presentation Topic :
PUSH, PUSHF, POP, POPF
Presented By :
Contents :
 The Stack
 Push
 Pop
 PushF
 PopF
A stack in one-dimensional data structure. Items are added and
removed from one end of the structure; that is, it is processed
in a “Last-in, first out” manner. The most recent addition to the
stack is called the top of the stack.
A program must set aside a block of memory to hold the stack.
We have been dong this by declaring a stack segment ;
For example :
.STACK 100H
THE STACK
To add a new word to the stack we PUSH it on. The syntax is
PUSH source
Where source is a 16-bit register or memory word.
For example,
PUSH AX
Execution of PUSH causes the following to happen :
1. SP is decreased by 2.
2. A copy of the source content is moved to the address specified
by SS:SP. The source is unchanged.
PUSH AND PUSHF
The instruction PUSHF, which has no operands, pushes
the contents of the FLAGS register onto the stack.
Initially SP contains the offset address of the memory
location immediately following the stack segment; the
first PUSH decreases SP by 2, making it point to the last
word in the stack segment. Because each PUSH
decreases SP, the stack grows toward the beginning of
memory
PUSH AND PUSHF
FIGURE : EMPTY STACK
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
1234
SP
5678
0100
AX
BX
STACK(empty)
SP
FIGURE : AFTER PUSH AX
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
1234
1234
SP
5678
00FE
AX
BX
STACK
SP
FIGURE : AFTER PUSH BX
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
5678
1234
1234
SP
5678
00FC
AX
BX
STACK
SP
To remove the top item from the stack we POP it. The Syntax is
POP destination
Where destination is a 16-bit register (except IP) or memory word. For example,
POP BX
Executing POP causes this to happen:
1. The content of SS:SP (the top the stack) is moved to the destination
2. SP is increased by 2.
POP AND POPF
The instruction POPF pops the top of the stack into the FLAGS
Register. There is no effect of PUSH, PUSHF, POP, POPF on the flags.
Such as
Illegal : PUSH DL
Is illegal. So is a push of immediate data, such as
Illegal : PUSH 2
FIGURE : BEFORE POP
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
5678
1234
FFFF
SP
0001
00FC
CX
DX
STACk
SP
FIGURE : AFTER POP CX
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
5678
1234
5678
SP
0001
00FE
CX
BX
STACK
SP
FIGURE : AFTER POP DX
offset
00F0
00F2
00FA
00F4
00F6
00F8
00FC
00FE
0100
5678
1234
5678
SP
1234
0100
CX
DX
STACK(empty)
SP
THANK YOU
END

More Related Content

PPTX
How can I use GNU cotreutils & other command line tools to get a sorted list ...
PPTX
File handling functions
PDF
How to reset root passwords on rhel 7 and cent os 7 linux systems
PPTX
Microprocessor presentation
PDF
Introduction to Microprocessors
PPT
Microprocessor ppt
PPTX
1.arithmetic & logical operations
PPT
Presentation
How can I use GNU cotreutils & other command line tools to get a sorted list ...
File handling functions
How to reset root passwords on rhel 7 and cent os 7 linux systems
Microprocessor presentation
Introduction to Microprocessors
Microprocessor ppt
1.arithmetic & logical operations
Presentation

Viewers also liked (10)

PPT
Cpu speed, wordlength.8
PPT
Arithmetic & logical operations in 8051
PPTX
Microprocessor
PPT
PDF
itft-Clock generator
PPT
Central processor amd memory
PPT
clock synchronization in Distributed System
PPT
Computer Fundamentals
PPT
8085 microprocessor architecture ppt
PDF
Computer Concepts PPT
Cpu speed, wordlength.8
Arithmetic & logical operations in 8051
Microprocessor
itft-Clock generator
Central processor amd memory
clock synchronization in Distributed System
Computer Fundamentals
8085 microprocessor architecture ppt
Computer Concepts PPT
Ad

Similar to Microprocessor & assembly language (9)

PDF
Lecture 05 NOP and Stack Group of Instructions
PPTX
Stack Memory Organization of 8086 Microprocessor
PPTX
Stack and its usage in assembly language
PPTX
What is Stack? Application of Stack
PPTX
Stack in 8085 microprocessor
PPT
Stack & queue
PPTX
B sc e 5.2 mp unit 2 soft ware(alp)
PPT
7. Stacks and subroutine.pptfor engineering student
Lecture 05 NOP and Stack Group of Instructions
Stack Memory Organization of 8086 Microprocessor
Stack and its usage in assembly language
What is Stack? Application of Stack
Stack in 8085 microprocessor
Stack & queue
B sc e 5.2 mp unit 2 soft ware(alp)
7. Stacks and subroutine.pptfor engineering student
Ad

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Machine learning based COVID-19 study performance prediction
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
A Presentation on Artificial Intelligence
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
sap open course for s4hana steps from ECC to s4
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
Machine Learning_overview_presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Machine learning based COVID-19 study performance prediction
Mobile App Security Testing_ A Comprehensive Guide.pdf
Network Security Unit 5.pdf for BCA BBA.
“AI and Expert System Decision Support & Business Intelligence Systems”
A Presentation on Artificial Intelligence
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Chapter 3 Spatial Domain Image Processing.pdf
sap open course for s4hana steps from ECC to s4
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...

Microprocessor & assembly language

  • 2. Presentation Topic : PUSH, PUSHF, POP, POPF Presented By :
  • 3. Contents :  The Stack  Push  Pop  PushF  PopF
  • 4. A stack in one-dimensional data structure. Items are added and removed from one end of the structure; that is, it is processed in a “Last-in, first out” manner. The most recent addition to the stack is called the top of the stack. A program must set aside a block of memory to hold the stack. We have been dong this by declaring a stack segment ; For example : .STACK 100H THE STACK
  • 5. To add a new word to the stack we PUSH it on. The syntax is PUSH source Where source is a 16-bit register or memory word. For example, PUSH AX Execution of PUSH causes the following to happen : 1. SP is decreased by 2. 2. A copy of the source content is moved to the address specified by SS:SP. The source is unchanged. PUSH AND PUSHF
  • 6. The instruction PUSHF, which has no operands, pushes the contents of the FLAGS register onto the stack. Initially SP contains the offset address of the memory location immediately following the stack segment; the first PUSH decreases SP by 2, making it point to the last word in the stack segment. Because each PUSH decreases SP, the stack grows toward the beginning of memory PUSH AND PUSHF
  • 7. FIGURE : EMPTY STACK offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 1234 SP 5678 0100 AX BX STACK(empty) SP
  • 8. FIGURE : AFTER PUSH AX offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 1234 1234 SP 5678 00FE AX BX STACK SP
  • 9. FIGURE : AFTER PUSH BX offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 5678 1234 1234 SP 5678 00FC AX BX STACK SP
  • 10. To remove the top item from the stack we POP it. The Syntax is POP destination Where destination is a 16-bit register (except IP) or memory word. For example, POP BX Executing POP causes this to happen: 1. The content of SS:SP (the top the stack) is moved to the destination 2. SP is increased by 2. POP AND POPF
  • 11. The instruction POPF pops the top of the stack into the FLAGS Register. There is no effect of PUSH, PUSHF, POP, POPF on the flags. Such as Illegal : PUSH DL Is illegal. So is a push of immediate data, such as Illegal : PUSH 2
  • 12. FIGURE : BEFORE POP offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 5678 1234 FFFF SP 0001 00FC CX DX STACk SP
  • 13. FIGURE : AFTER POP CX offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 5678 1234 5678 SP 0001 00FE CX BX STACK SP
  • 14. FIGURE : AFTER POP DX offset 00F0 00F2 00FA 00F4 00F6 00F8 00FC 00FE 0100 5678 1234 5678 SP 1234 0100 CX DX STACK(empty) SP