EMAC PRIMER Instruction Manual page 31

Table of Contents

Advertisement

LESSON 4: Eight-Bit Addition
NEW INSTRUCTIONS
ADD
C
The C register is added to the A register with the result being stored in the A register. The Z,S,P,CY and
AC flags are affected.
MOV
A,B
The contents of the B register are copied to register A. No flags are affected.
This program adds the B and C registers together and stores the result in the A register. This is done by copying the value
of B to A and then adding the value of C to A.
org
loop:
mov
add
rst
end
ADDRESS
FF01
FF02
FF03
To test the ADD C instruction, load the program into memory, press the reset button and do the following:
1)
The B and C registers will be loaded with numbers whose sum will not be greater than 9 so that the result will not
have to be translated to decimal to see that the instruction worked properly. Load the BC register pair with 0403,
which is the same as loading B with 4 and C with 3, then run the program. The program will stop at FF03 because
of the RST 7 instruction. (Because the microprocessor is so fast the program stops almost immediately, so you
may think that it didn't actually run the program, but by examining the registers you will see that it did.) If you
examine the A register you will see that it has the value 7, and if you convert the flag register to binary you will see
that bit 0 (the carry flag) is 0 which means that the result of the addition was small enough to fit in the A register.
2)
Press the reset button and load the BC register pair with FFFF then run the program. When the program stops at
FF03 examine the A register and flag register and you will see that the A register is now FE and that bit 0 of the
flag register (the carry flag) is now 1 which indicates that the result of the addition was too big to fit in the A
register.
op code = 81
op code = 78
0ff01
a,b
; A is a copy of B
c
; Add C to A
7
; return control to MOS
DATA
INSTRUCTION
78
MOV
81
ADD
FF
RST
A,B
C
7
31

Advertisement

Table of Contents
loading

Table of Contents