Lecture 7
Lecture 7
12B
CF3
FFFB
FFFC
FFFD F3
FFFE 12
FFFF SP
The POP Instruction
• POP D (1 Byte Instruction)
– Copy the contents of the memory location
pointed to by the SP to register E
– Increment SP
– Copy the contents of the memory location
pointed to by the SP to register D
– Increment SP
D E
12 F3
FFFB
FFFC
FFFD F3 SP
FFFE 12
FFFF
Saving Information on the Stack
• There are two methods to add data to the
stack:
– Direct method
– Indirect method
Saving Information on the Stack
• Direct method
– the stack pointers address is loaded into the
stack pointer register directly
LXI SP,8000H
LXI H,1234H
PUSH H
POP D
HLT
Saving Information on the Stack
• Indirect method
– the stack pointer’s address is loaded into the
stack pointer register via another register pair.
LXI H,8000H
SPHL
LXI H,1234H
PUSH H
POP D
HLT
PSW Register Pair
• The 8085 recognizes one additional register
pair called the PSW (Program Status Word).
– This register pair is made up of the
Accumulator and the Flags registers.
• It is possible to push the PSW onto the stack,
do whatever operations are needed, then POP
it off of the stack.
PUSH PSW Register Pair
• PUSH PSW (1 Byte Instruction)
– Decrement SP
– Copy the contents of register A to the memory location
pointed to by SP
– Decrement SP
– Copy the contents of Flag register to the memory
location pointed to by SP
Pop PSW Register Pair
• POP PSW (1 Byte Instruction)
– Copy the contents of the memory location
pointed to by the SP to Flag register
– Increment SP
– Copy the contents of the memory location
pointed to by the SP to register A
– Increment SP
Modify Flag Content using PUSH/POP
• We want to Reset the Zero Flag