list p=16F84A ; list directive to define processor
__config 3FF9
;
;specify SFRs
pcl equ 02
status equ 03
porta equ 05
trisa equ 05
portb equ 06
trisb equ 06
;
pointer equ 10
delcntr1 equ 11
delcntr2 equ 12
;
org 00
;Initialise
start bsf status,5 ;select memory bank 1
movlw B'00011000'
movwf trisa ;port A according to above pattern
movlw 00
movwf trisb ;all port B bits output
bcf status,5 ;select bank 0
clrf portb
clrf pointer
;
;The "main" program starts here
movlw 00 ;clear all bits in port A
movwf porta
movwf pointer ;also clear pointer
loop movf pointer,0 ;move pointer to W register
call table
movwf portb ;move W register, updated from table SR, to portB
call delay
loop2 btfsc porta,0
incf pointer,1
btfsc porta,7
clrf pointer
goto loop
;
delay movlw D'255'
movwf delcntr2
outer movlw D'255'
movwf delcntr1
inner nop
nop
nop
nop
nop
decfsz delcntr1,1
goto inner
decfsz delcntr2,1
goto outer
return
;Holds Lookup Table
table addwf pcl,1
retlw B'01111110' ;0
retlw B'00110000' ;1
retlw B'01101101' ;2
retlw B'01111001' ;3
retlw B'00110011' ;4
retlw B'01011011' ;5
retlw B'01011111' ;6
retlw B'01110000' ;7
retlw B'01111111' ;8
retlw B'01111011' ;9
retlw B'01111101' ;a
retlw B'00011111' ;b
retlw B'00001101' ;c
retlw B'00111101' ;d
retlw B'01001111' ;e
retlw B'01000111' ;f
;end of program'
END