EMAC PRIMER Instruction Manual page 72

Table of Contents

Advertisement

FF0E
FF0F
FF10
FF11
FF12
FF13
FF14
FF15
FF16
FF17
FF18
FF19
FF1A
FF1B
FF1C
FF1D
FF1E
FF1F
To see how the compare instructions work in a program, load the program into memory and verify that the data was
entered correctly then press the reset button and do the following:
CURRENT PC
FF01
Set a breakpoint at address FF0D and run the program. The program will pause until a key is pressed (
because of the keyin service), so press the "3" key. After that, the program will stop at the breakpoint
address which is the address of the CMP L instruction.
FF0D
The keyin service should return the L register with the value 3 and the A register will be 0 because of the
MVI A,0 instruction that was executed before the breakpoint was encountered. Execute the CMP L
instruction by single stepping then examine the flag register. The A register is less than L and of course it
is not equal, so, according to the definition, the carry flag will be 1 and the zero flag will be 0.
FF0E
Single step and the JNZ FF14 instruction will be executed and you will see that because the zero flag is 0,
the program counter will now point to address FF14. This skips the code that is to be done when the "0"
key is pressed and goes to address FF14.
FF14
The following instructions will check to see if the "3" key was pressed. Single step once to execute MOV
A,L and one more time to execute CPI 3. In this comparison L register is loaded into A and 3 is
compared to it. Since A is 3 the zero flag will be 1 and the carry flag will be 0. Examine the flag register to
verify this.
FF17
This is the address of the JNZ FF03 instruction. Single step once and the jump will not occur because the
zero flag is 1, instead, the program counter will point to the instruction following this one. The instructions
following JNZ FF03 rotate the value in the B register to the right when the "3" key is pressed.
FF1A
Set a breakpoint at FF0D again then run from the current address. The keyin service will wait on a key to
be pressed, so press the "0" key and the program will stop at FF0D.
FF0D
This is the address of the CMP L instruction again. The keyin service will return the L register with 0 which
is the value of the "0" key and the A register has been loaded with 0 by the MVI A,0 instruction. Execute
the CMP L instruction by single stepping and this time, since A equals L the Z flag will be 1 and the CY
flag will be 0.
FF0E
Single step and JNZ FF14 instruction won't execute this time because the zero flag is 1, instead the
program counter will point to the instruction following this one.
FF11
The following instructions are executed when the "0" key is pressed. Single step to FF14 and the value in
the B register will be rotated to the left.
FF14
Single step and the L register will be copied to the A register. Single step again and the CPI 3 instruction
will be executed and since A is 0, the Z flag will be 0 and the CY flag will be 1.
FF17
The program counter now points to the JNZ FF03 instruction again and since the Z flag is 0 the NZ
conditional is true, so single stepping this will cause the program counter to jump to FF03.
C2
JNZ
FF14
14
FF
78
MOV
A,B
07
RLC
47
MOV
B,A
7D
MOV
A,L
FE
CPI
3
03
C2
JNZ
FF03
03
FF
78
MOV
A,B
0F
RRC
47
MOV
B,A
C3
JMP
FF03
03
FF
72

Advertisement

Table of Contents
loading

Table of Contents