EMAC PRIMER Instruction Manual page 73

Table of Contents

Advertisement

FF03
Run the program full speed from here to see the way the pressing keys affects the digital output LEDs.
The previous program used compare instructions to check for equality of two values. The compare instructions can also
be used to tell whether a value is greater or less than another value. The following program compares the H and L register
and causes the digital output LEDs to show different patterns depending on the relative sizes of H and L. If H is greater
than L then the two left LEDs will shine, if L is greater than H then the right two LEDs will shine and if H = L then the middle
two LEDs will shine.
leds
equ
org
loop:
mov
cmp
jc
jz
mvi
jmp
lgreat:
mvi
jmp
equal:
mvi
patout:
out
rst
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
FF0C
FF0D
FF0E
FF0F
FF10
FF11
FF12
FF13
FF14
FF15
FF16
FF17
Load the program into memory and press the reset button then do the following:
11h
; output port for digital output LEDs
0ff01h
a,h
; put H in A
l
; set flags according to value of A & L
lgreat
;if CY=1 then L>A, so jump
equal
; if Z = 1 then A=L, so jump
; At this point in the program H is not less than L
; and it is not equal to L, so H is greater than L.
a,00111111b ; pattern for H>L
patout
; output the pattern
a,11111100b ; pattern for L>H
patout
; output the pattern
a,11100111b ; pattern for H=L
leds
; display bit pattern
7
; end of program
DATA
INSTRUCTION
7C
MOV
BD
CMP
DA
JC
0E
FF
CA
JZ
13
FF
3E
MVI
3F
C3
JMP
15
FF
3E
MVI
FC
C3
JMP
15
FF
3E
MVI
E7
D3
OUT
11
FF
RST
A,H
L
FF0E
FF13
A,3F
FF15
A,FC
FF15
A,E7
11
7
73

Advertisement

Table of Contents
loading

Table of Contents