EMAC PRIMER Instruction Manual page 56

Table of Contents

Advertisement

LESSON 18: The Stack and Related Instructions
NEW INSTRUCTIONS
PUSH PSW
Put the processor status word ( A register and flag register ) on the stack. No flags are affected.
PUSH B
Put the BC register pair on the stack. No flags are affected.
POP
PSW
Get the processor status word (A register and flag register) from the stack. Z,S,P,CY and AC flags are
affected.
POP
B
Get the BC register pair from the stack. No flags are affected.
The 8085 microprocessor allows you to choose an area of RAM to be a section of temporary storage called a stack. The
key element of the stack is the 8085's internal stack pointer register (SP). The SP can be set to start at any address in
memory, but it is best to leave it equal to or less than the address that is selected by the MOS.
Memory is most often shown with low addresses being at the top of a listing, and higher addresses being at the bottom as
in the example below:
ADDRESS
( this is not a working program )
FF01
FF02
FF03
FF04
FF05
FF06
FF07
:
: ( addresses FF08 - FFCF )
:
FFD0
FFD1
FFD2
FFD3
SP->
FFD4
For example, if SP = FFD4 (as in the above example) and BC = 1234 and a PUSH B instruction is executed, the B register
is copied to memory address SP - 1 (FFD3) and the C register is copied to memory address SP - 2 (FFD2), then 2 is
subtracted from SP so that the stack now looks like this:
STACK ADDRESS
( this is not a working program )
:
:
FFD0
FFD1
SP->
FFD2
FFD3
FFD4
If the A register is 56 and the flags are 78 and a PUSH PSW is executed then the stack will look like this:
STACK ADDRESS
( this is not a working program )
:
:
SP->
FFD0
FFD1
FFD2
FFD3
FFD4
op code = F5
op code = C5
op code = F1
op code = C1
DATA
INSTRUCTION
F3
DI
21
LXI
H,FF20
20
FF
22
SHLD FFE9
E9
FF
40
23
61
03
00
STACK DATA
DESCRIPTION
40
23
34
VALUE FROM C REGISTER
12
VALUE FROM B REGISTER
00
STACK DATA
DESCRIPTION
78
VALUE FROM FLAGS
56
VALUE FROM A REGISTER
34
VALUE FROM C REGISTER
12
VALUE FROM B REGISTER
11
56

Advertisement

Table of Contents
loading

Table of Contents