EMAC PRIMER Instruction Manual page 62

Table of Contents

Advertisement

FF0C
Single step the XTHL instruction and HL is now the number of additions that are left to do, and the value
on the stack holds the sum from the addition.
FF0D
Single step and 1 will be subtracted from the number of additions left to do in the HL register.
FF0E
Single step and the H register will be copied to the A register.
FF0F
Single step and the L register will be ORed with the A register and since both of the registers are 0 the
result in the A register will be 0 and the zero flag will be set.
FF10
Single step and the XTHL instruction will swap the value on the stack with the value in HL. This makes HL
the sum again and the value on the stack is the number of additions left to go (0000).
FF11
Single step and the PC register will be loaded with FF14 which is the address of the instruction following
the JNZ FF07 instruction. This is because the zero flag must be 0 in order for the instruction to load the
PC register with FF07.
FF14
Examine the SP register then single step and examine it again. Before single stepping, SP was FFD2 and
after single stepping it is FFD4, which is the value it had when the program started. The POP PSW
instruction was used just to restore the stack to its original starting position, the value that was loaded into
the A register and flag register was not needed.
FF15
This is the end of the program. Examine the BC and HL register pairs and they should be 0001 and FFFE
respectively, which represents the number 0001FFFE which is the product of FFFF and 0002.
Try other values for DE and HL (HL must be greater than 0). Take note that since this program uses repeating
additions to perform multiplication the larger the value of HL the longer the program will take to perform the multiplication.
For example, if HL = FFFF the program will take approximately 3 seconds to perform the multiplication.
62

Advertisement

Table of Contents
loading

Table of Contents