#include "P16f877a.inc"
__config 0x399A
cblock 0x20
offset
endc
COUNT1 equ 2DH
COUNT2 equ 2EH
pcl equ 02h
org 0x00
bsf STATUS,5 ; set bit 5 of STATUS to change to bank 1
banksel TRISB
clrf TRISB
clrf TRISD ;set port D to output
bcf STATUS,5
banksel PORTB
clrf PORTB
again movlw 1 ;start at entry 1
movwf offset
Loop
movlw 0x00 ;get high 8 bits of Table address (Page 0)
movwf PCLATH ;store into PCLATH
movlw 0x50
addwf offset,w
btfsc STATUS,C
incf PCLATH
call Table
movwf PORTD
call DELAY
incf offset,f ;move to next entry
movlw 6 ;length of table
xorwf offset,W
btfss STATUS,Z ;reached the end?
goto Loop ;no so keep going
goto again ;yes so reset offset
org 0x50
Table: movwf pcl
retlw 0x88
retlw 0x70
retlw 0x38
retlw 0xff
retlw 0xff
DELAY ; common delay for all condition
movlw d'200'
movwf COUNT1
DELAY1
decfsz COUNT2,1
goto DELAY1
decfsz COUNT1,1
goto DELAY1
return
end