call
delay
;(3)
;delay for a while
set
c
;;shift lamp state left through
rlc
lamp
;(4)
;;carry flag (fill LSB 1)
sz
c
;if all LEDs have been lit?
jmp
llamp
;(5)
;;no. continue shift left loop
rrc
lamp
;(6)
;;yes. restore lamp state
rlamp:
;shift lamp right loop
mov
a,lamp
;load lamp state
mov
pa,a
;output lamp state to port A
call
delay
;delay for a while
set
c
;;shift lamp state right through
rrc
lamp
;(7)
;;carry flag (fill MSB 1)
sz
c
;if all LEDs have been lit?
jmp
rlamp
;;no. continue shift right loop
rlc
lamp
;;yes. restore lamp state
jmp
llamp
;(8)
;repeat from shift lamp left loop
delay
proc
;delay subroutine
mov
a,2fh
;; set counters
mov
count1,a
;;
mov
count2,a
;;
d1:
sdz
count2
;count down count2
jmp
d1
;
sdz
count1
;count down count1
jmp
d1
;
ret
delay endp
end
Program description
This short program allows an array of 8 LEDs to be illuminated in turn first
in a left moving direction and then in a contrary right moving direction. The
program begins by first setting up the ports as either output or input as
shown in section (1). Here, as all ports are to be set as outputs, the control
register for PA, known as PAC should only contain zeros. In section (2) bit
0 of Port A is set low which illuminates the first LED. Section (3) is a time
delay to allow the LED illumination to be visible. In section (4) the RLC or
rotate left instruction is used to move the illuminated LED one step to the
left using the lamp register and the accumulator. At section (5) the lamp
register is tested for all zeros. If this is the case, all the LEDs have been
illuminated and the program jumps to the next section illuminating the
LEDs in turn, one step to the right. This time the RRC or rotate right
command is used as shown in section (6). A process similar to the above is
repeated as shown in section (7). Finally the lamp register is checked for all
zeros, which is an indication that all the LEDs have been illuminated. If so
the program repeats the cycle jumping back to the beginning as shown in
section (8) and starting the pattern with the left moving LEDs.
Chapter 15 Input/Output Applications
187
Summary of Contents for HT-IDE
Page 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Page 12: ...HT IDE User s Guide 2 ...
Page 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Page 24: ...HT IDE User s Guide 14 ...
Page 70: ...HT IDE User s Guide 60 ...
Page 76: ...HT IDE User s Guide 66 ...
Page 92: ...HT IDE User s Guide 82 ...
Page 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Page 94: ...HT IDE User s Guide 84 ...
Page 148: ...HT IDE User s Guide 138 ...
Page 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Page 154: ...HT IDE User s Guide 144 ...
Page 192: ...HT IDE User s Guide 182 ...
Page 194: ...HT IDE User s Guide 184 ...
Page 218: ...HT IDE User s Guide 208 ...
Page 235: ...P a r t V Appendix Part V Appendix 225 ...
Page 236: ...HT IDE User s Guide 226 ...
Page 250: ...HT IDE User s Guide 240 ...