#include <p18f26j11.inc>
CONFIG XINST = OFF ; Extended Instruction Set (Disabled)
CONFIG IOL1WAY = ON
CONFIG OSC = INTOSC
CONFIG WDTEN = OFF
CONFIG DEBUG = ON
cblock 0x5F
huns
tens
ones
temp
fetchcount
endc
;
;Reset vector:
org 0X00
GOTO START
FETCH
DECF fetchcount ;Enables software to make decisions as to which digit is being
BTFSS fetchcount,1 ;considered,
GOTO ONES ;
BTFSC fetchcount,0 ;fetchcount 3 (1,1) = hundreds
GOTO HUNS ;fetchcount 2 (1,0) = tens
GOTO TENS ;fetchcount 1 (0,1) = ones
HUNS MOVFF huns,temp
GOTO LOOKUP
TENS MOVFF tens,temp
GOTO LOOKUP
ONES MOVFF ones,temp
GOTO LOOKUP
LOOKUP
MOVFF temp,WREG ;temp register allows for adjustable PCL reference without multiple lookup tables
ADDWF PCL,f
RETLW b'01111110' ;0
RETLW b'00001100' ;1
RETLW b'10110110' ;2
RETLW b'10011110' ;3
RETLW b'11001100' ;4
RETLW b'11011010' ;5
RETLW b'11111010' ;6
RETLW b'00001110' ;7
RETLW b'11111110' ;8
RETLW b'11001110' ;9
START
;initialise variables
CLRF ones
CLRF tens
CLRF huns
CLRF fetchcount
MOVLW d'4'
MOVFF WREG,fetchcount
MOVLW d'6' ;1
MOVWF huns
MOVLW d'4' ;2
MOVWF tens
MOVLW d'8' ;3
MOVWF ones
Main
CALL FETCH
MOVFF WREG,huns
CALL FETCH
MOVFF WREG,tens
CALL FETCH
MOVFF WREG,ones
MOVLW d'4'
MOVWF fetchcount
END