EMAC PRIMER Instruction Manual page 64

Table of Contents

Advertisement

FF0D
FF0E
FF0F
FF10
FF11
FF12
FF13
FF14
FF15
FF16
FF17
FF18
FF19
FF1A
FF1B
FF1C
FF1D
FF1E
FF1F
FF20
FF21
FF22
Load the program into memory and run it; The program should display 3 different patterns on the discrete LEDs, one after
the other, and repeat the patterns again. The delay between each pattern should slowly decrease until the patterns are
changing so quickly that they are not observable. Then the delay will suddenly become much longer and then slowly
decrease again. If the program is working as described, press the reset button and do the following:
CURRENT PC
FF01
Single step to the first CALL instruction at address FF06 and examine the stack content (it will be 0000)
and the stack pointer will be FFD4.
FF06
Single step and the CALL FF16 instruction will be executed causing the program to jump to FF16, the start
of the subroutine.
FF16
The CALL instruction has put the address of the instruction following it, on the stack. Examine the stack
contents to verify this. Examine and write down the value of the PSW and HL then single step twice which
will first PUSH the HL register pair then PUSH the PSW on the stack. Set a breakpoint at FF20, then run
from the current address.
FF20
This is the first instruction following the delay loop. Compare the PSW and HL with the values that you
wrote down and you will see that they have been changed. Execute the POP PSW instruction by single
stepping and the original value of the PSW will be restored.
FF21
Single step again and the POP H instruction will be executed which will restore the original value of HL.
Notice that the order of POPing data from the stack is the opposite of the order of PUSHing. This is
because the last item PUSHed on the stack is the first one that can be POPed off. POPing the PSW and
HL off the stack has restored the return address (FF09) to the top of the stack. Examine the stack
contents to verify this.
FF22
Execute the RET instruction by single stepping and it will remove the return address from the stack and
jump to the address. The stack contents will be 0000 again with the stack pointer at FFD4 after the RET
instruction.
FF09
Single step and the A register will be complemented.
FF0A
Now that you understand what happens during the CALL of a subroutine, check the stack content to verify
that it is 0000. Set a breakpoint at the address (FF0D) of the instruction following this CALL and run from
the current address.
FF0D
The subroutine has output the bit pattern that was in the A register and paused for period of time
proportional to the value of HL and returned to this address.
3E
MVI
A,55
55
CD
CALL FF16
16
FF
25
DCR
H
C3
JMP
FF04
04
FF
E5
PUSH H
F5
PUSH PSW
D3
OUT
11
11
2B
DCX
H
7C
MOV
A,H
B5
ORA
L
C2
JNZ
FF1A
1A
FF
F1
POP
PSW
E1
POP
H
C9
RET
64

Advertisement

Table of Contents
loading

Table of Contents