; LisPh03
; Listen to the Photon
; duty=1/3

	LIST	P=PIC16F84
	LIST	R=DECIMAL
	include	"p16f84.inc"
	__config _CP_OFF&_PWRTE_OFF&_WDT_OFF&_XT_OSC

pval1    equ 0x10
pval2    equ 0x11
pval3    equ 0x12
pval4    equ 0x13
pval5    equ 0x14
pval6    equ 0x15
pval7    equ 0x16
pval8    equ 0x17
pval9    equ 0x18
pval10   equ 0x19
pval11   equ 0x1a
pval12   equ 0x1b
pcnt1    equ 0x1c
pcnt2    equ 0x1d
pcnt3    equ 0x1e
pcnt4    equ 0x1f
pcnt5    equ 0x20
pcnt6    equ 0x21
pcnt7    equ 0x22
pcnt8    equ 0x23
pcnt9    equ 0x24
pcnt10   equ 0x25
pcnt11   equ 0x26
pcnt12   equ 0x27
led_outA equ 0x28
led_outB equ 0x29
tmp      equ 0x2a

;PortA 0-4 
;PortB 0-7 LED Anode (HiActive)

    org 0
    goto    start
    retfie
    retfie
    retfie
    retfie
start
    bcf     STATUS,RP0
    movlw   0xFF
    movwf   PORTA
    movlw   0x00
    movwf   PORTB

    bsf     STATUS,RP0
    movlw   0x00
    movwf   TRISA
    movlw   0x00
    movwf   TRISB
    movlw   0x7F
    movwf   OPTION_REG

    bcf     STATUS,RP0

    movlw   90
    movwf   pval1
    movwf   pcnt1
    movlw   80
    movwf   pval2
    movwf   pcnt2
    movlw   72
    movwf   pval3
    movwf   pcnt3
    movlw   68
    movwf   pval4
    movwf   pcnt4
    movlw   60
    movwf   pval5
    movwf   pcnt5
    movlw   54
    movwf   pval6
    movwf   pcnt6
    movlw   48
    movwf   pval7
    movwf   pcnt7
    movlw   45
    movwf   pval8
    movwf   pcnt8
    movlw   40
    movwf   pval9
    movwf   pcnt9
    movlw   36
    movwf   pval10
    movwf   pcnt10
    movlw   34
    movwf   pval11
    movwf   pcnt11
    movlw   30
    movwf   pval12
    movwf   pcnt12
    clrf    led_outA
    clrf    led_outB

Main_Loop

    decfsz  pcnt1,f
     goto   cnt10
    movlw   0x01
    xorwf   led_outB,f
    rrf     led_outB,w
    movf    pval1,w
    skpc
     rrf    pval1,w
    movwf   pcnt1
cnt10
    decfsz  pcnt2,f
     goto   cnt20
    movlw   0x02
    xorwf   led_outB,f
    rrf     led_outB,w
    movwf   tmp
    rrf     tmp,f
    movf    pval2,w
    skpc
     rrf    pval2,w
    movwf   pcnt2
cnt20
    decfsz  pcnt3,f
     goto   cnt30
    movlw   0x04
    xorwf   led_outB,f
    rrf     led_outB,w
    movwf   tmp
    rrf     tmp,f
    rrf     tmp,f
    movf    pval3,w
    skpc
     rrf    pval3,w
    movwf   pcnt3
cnt30
    decfsz  pcnt4,f
     goto   cnt40
    movlw   0x08
    xorwf   led_outB,f
    rrf     led_outB,w
    movwf   tmp
    rrf     tmp,f
    rrf     tmp,f
    rrf     tmp,f
    movf    pval4,w
    skpc
     rrf    pval4,w
    movwf   pcnt4
cnt40
    decfsz  pcnt5,f
     goto   cnt50
    movlw   0x10
    xorwf   led_outB,f
    rlf     led_outB,w
    movwf   tmp
    rlf     tmp,f
    rlf     tmp,f
    rlf     tmp,f
    movf    pval5,w
    skpc
     rrf    pval5,w
    movwf   pcnt5
cnt50
    decfsz  pcnt6,f
     goto   cnt60
    movlw   0x20
    xorwf   led_outB,f
    rlf     led_outB,w
    movwf   tmp
    rlf     tmp,f
    rlf     tmp,f
    movf    pval6,w
    skpc
     rrf    pval6,w
    movwf   pcnt6
cnt60
    decfsz  pcnt7,f
     goto   cnt70
    movlw   0x40
    xorwf   led_outB,f
    rlf     led_outB,w
    movwf   tmp
    rlf     tmp,f
    movf    pval7,w
    skpc
     rrf    pval7,w
    movwf   pcnt7
cnt70
    decfsz  pcnt8,f
     goto   cnt80
    movlw   0x80
    xorwf   led_outB,f
    rlf     led_outB,w
    movf    pval8,w
    skpc
     rrf    pval8,w
    movwf   pcnt8
cnt80
    decfsz  pcnt9,f
     goto   cnt90
    movlw   0x01
    xorwf   led_outA,f
    rrf     led_outA,w
    movf    pval9,w
    skpc
     rrf    pval9,w
    movwf   pcnt9
cnt90
    decfsz  pcnt10,f
     goto   cnt100
    movf    pval10,w
    movwf   pcnt10
    movlw   0x02
    xorwf   led_outA,f
    rrf     led_outA,w
    movwf   tmp
    rrf     tmp,f
    movf    pval10,w
    skpc
     rrf    pval10,w
    movwf   pcnt10
cnt100
    decfsz  pcnt11,f
     goto   cnt110
    movlw   0x04
    xorwf   led_outA,f
    rrf     led_outA,w
    movwf   tmp
    rrf     tmp,f
    rrf     tmp,f
    movf    pval11,w
    skpc
     rrf    pval11,w
    movwf   pcnt11
cnt110
    decfsz  pcnt12,f
     goto   cnt120
    movlw   0x08
    xorwf   led_outA,f
    rrf     led_outA,w
    movwf   tmp
    rrf     tmp,f
    rrf     tmp,f
    rrf     tmp,f
    movf    pval12,w
    skpc
     rrf    pval12,w
    movwf   pcnt12
cnt120
    movf    led_outB,w
    movwf   PORTB
    movf    led_outA,w
    movwf   PORTA

    goto    Main_Loop

    END
