#include ht48c10-1.inc ;------------------------------------------------------- value .section 'data' ;== data section == count1 db ? ;delay loop counter 1 count2 db ? ;delay loop counter 2 count3 db ? ;delay loop counter 3 flash db ? ;light flash register rglight db ? ;light register ;------------------------------------------------------- main .section at 0 'code' ;== program section == org 00H ; jmp start ; org 04h ;external interrupt subroutine reti ;for guarantee org 08h ;timer/event 0 interrupt subroutine reti ;for guarantee org 0ch ;timer/event 1 interrupt subroutine reti ;for guarantee start: ; clr intc ;initialize registers clr tmrc ;to guarantee performance clr tmr ;(interrupts) set pac ;(ports) set pbc ;(input mode) set pcc ; main: MOV a,0 ;(1) ; MOV pac,a ;set port A to output port MOV pa,a ;zero port A (all light on) loop: ;light loop MOV a,0 ;;load table-read pointer MOV tblp,a ;; tabrdl rglight ;(2) ;load light state by looking up table MOV a,rglight ;(3) ;;output light state to port A MOV pa,a ;; call delayl ;(4) ;delay for a 'long' while inc tblp ;(5) ; MOV a,7 ;load flash counter MOV flash,a ; flash1: ;flash1 loop tabrdl rglight ;load light state MOV a,rglight ;; MOV pa,a ;;output light state to port A call delays ;(6) ;delay for a 'little' while inc tblp ; sdz flash ;if flash light over? jmp flash1 ;no. flash again tabrdl rglight ;(yes. go ahead) load light state MOV a,rglight ;;output light state to port A MOV pa,a ;; call delaym ;(7) ;delay for a 'medium' while inc tblp ; ;--------------------------------; tabrdl rglight ;load light state MOV a,rglight ;;output light state to port A MOV pa,a ;; call delayl ;delay for a 'long' while inc tblp ; MOV a,7 ;;load flash counter MOV flash,a ;; flash2: ;flash2 loop tabrdl rglight ;load light state MOV a,rglight ;;output light state to port A MOV pa,a ; call delays ;delay for a 'little' while inc tblp ; sdz flash ;if flash light over? jmp flash2 ;no. flash again tabrdl rglight ;(yes. go ahead) load light state MOV a,rglight ;;output light state to port A MOV pa,a ;; call delaym ;delay for a 'medium' while jmp loop ;repeat from light loop delayl proc ;'long' delay subroutine MOV a,07fh ;;load counters MOV count1,a ;; MOV count2,a ;; ;MOV count3,a ;; d1: ;sdz count3 ;;count down count3 ;jmp d1 sdz count2 ;;count down count2 jmp d1 sdz count1 ;;count down count1 jmp d1 ret delayl endp delaym proc ;'medium' delay subroutine MOV a,3fh ;;load counters MOV count1,a ;; MOV a,0ffh ;; MOV count2,a ;; ;MOV count3,a ;; d2: ;sdz count3 ;;count down count3 ;jmp d2 sdz count2 ;;count down count2 jmp d2 sdz count1 ;;count down count1 jmp d2 ret delaym endp delays proc ;'little' delay subroutine MOV a,0ffh ;;load counters MOV count1,a ;; MOV a,0ffh MOV count2,a ;; d3: sdz count2 ;;count down count2 jmp d3 sdz count1 ;;count down count1 jmp d3 ret delays endp org 300h ;TABLE ; RYG RYG dc 001h ;1110 1011 G R dc 002h ;1111 1011 O R dc 004h ;1110 1011 G R dc 008h ;1111 1011 O R dc 010h ;1110 1011 G R dc 020h ;1111 1011 O R dc 040h ;1110 1011 G R dc 080h ;1111 1011 O R dc 001h ;1101 1011 Y R dc 002h ;1011 1110 R G dc 004h ;1011 1111 R O dc 008h ;1011 1110 R G dc 010h ;1011 1111 R O dc 020h ;1011 1110 R G dc 040h ;1011 1111 R O dc 080h ;1011 1110 R G dc 0ffh ;1011 1111 R O dc 0ffh ;1011 1101 R Y end
|