;Nim for 12F629.asm ; 5-7-2014 list p=12F629 radix dec include "p12f629.inc" errorlevel -302 ; Dont complain about BANK 1 Registers during assembly __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ;Internal osc. ; globals counter equ 20h ;this is the first available file tempA equ 21h tempB equ 22h flickA equ 23h timerA equ 24h random equ 25h fileA equ 26h fileB equ 27h fileC equ 28h fileD equ 29h filezz equ 5Fh ;this is the last available file status equ 03h option_reg equ 81h ; bits on GPIO pin7 equ 0 ;GP0 pin6 equ 1 ;GP1 pin5 equ 2 ;GP2 and T0CkI pin4 equ 3 ;GP3 input only pin3 equ 4 ;GP4 pin2 equ 5 ;GP5 ;bits rp0 equ 5 ;bit 5 of the status register Start org 0x00 ;program starts at location 000 nop nop nop nop ;NOPs to get past reset vector address nop nop SetUp bsf status, rp0 ;Bank 1 movlw b'11110111' ;Turn on T0CKI, prescale for TMR0 = 1:256 movwf option_reg bcf status, rp0 ;bank 0 movlw 07h ;Set up W to turn off Comparator ports movwf CMCON ;must be placed in bank 0 clrf GPIO ;Clear GPIO of junk goto Main ;Delay 0.01 sec (10mS) ;1mS delay _1mS decfsz fileA,1 goto _1mS retlw 00 _10mS movlw 0Ah movwf fileB DelY nop decfsz fileA,1 goto DelY decfsz fileB,1 goto DelY retlw 00 ;100mS delay _100mS movlw 60h movwf fileB BB call _1mS decfsz fileB,1 goto BB retlw 00 _500mS movlw 32h movwf fileC CC call _10mS decfsz fileC,1 goto CC retlw 00 ;Clear the screen clr500mS bsf status, rp0 ;Bank 1 movlw b'11111111' ; movwf TRISIO ; bcf status, rp0 ;bank 0 call _500mS retlw 00 _1to19 clrf fileD bsf fileD,3 ;create 8h loops for each number 0000 1000 call show1 bsf fileD,3 call show2 bsf fileD,3 call show3 bsf fileD,3 call show4 bsf fileD,3 call show5 bsf fileD,3 call show6 bsf fileD,3 call show7 bsf fileD,3 call show8 bsf fileD,3 call show9 bsf fileD,3 call show10 bsf fileD,3 call show11 bsf fileD,3 call show12 bsf fileD,3 call show13 bsf fileD,3 call show14 bsf fileD,3 call show15 bsf fileD,3 call show16 bsf fileD,3 call show17 bsf fileD,3 call show18 bsf fileD,3 call show19 retlw 00 show1 bsf status, rp0 ;Bank 1 movlw b'11001101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00100110' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11111111' ;Set GP1,2 4 5 input to reduce brightness movwf TRISIO ; bcf status, rp0 ;bank 0 call _10mS decfsz fileD,1 ; goto show1 retlw 00 show2 bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11011101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000010' ;make GP 1 low movwf GPIO call _10mS decfsz fileD,1 ; goto show2 retlw 00 show3 bsf status, rp0 ;Bank 1 movlw b'11001101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010010' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show3 retlw 00 show4 bsf status, rp0 ;Bank 1 movlw b'11011111' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11100001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000110' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show4 retlw 00 show5 bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000100' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001111' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010000' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show5 retlw 00 show6 bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001011' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010100' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show6 retlw 00 show7 bsf status, rp0 ;Bank 1 movlw b'11101101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11111101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show7 retlw 00 show8 bsf status, rp0 ;Bank 1 movlw b'11001001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010110' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show8 retlw 00 show9 bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000100' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001101' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010010' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show9 retlw 00 show10 bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010111' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show10 retlw 00 show11 bsf status, rp0 ;Bank 1 movlw b'11111100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00100111' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101110' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show11 retlw 00 show12 bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11011100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show12 retlw 00 show13 bsf status, rp0 ;Bank 1 movlw b'11001100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show13 retlw 00 show14 bsf status, rp0 ;Bank 1 movlw b'11001010' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000101' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11111100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show14 retlw 00 show15 bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000101' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001110' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010001' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show15 retlw 00 show16 bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001010' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010101' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show16 retlw 00 show17 bsf status, rp0 ;Bank 1 movlw b'11101100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11111100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show17 retlw 00 show18 bsf status, rp0 ;Bank 1 movlw b'11001000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000001' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11100000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010111' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show18 retlw 00 show19 bsf status, rp0 ;Bank 1 movlw b'11101000' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000101' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001100' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010011' ; movwf GPIO call _10mS decfsz fileD,1 ; goto show19 retlw 00 showU bsf status, rp0 ;Bank 1 movlw b'11101011' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010110' ; movwf GPIO call _10mS decfsz fileD,1 ; goto showU retlw 00 showL bsf status, rp0 ;Bank 1 movlw b'11111011' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101011' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010100' ; movwf GPIO call _10mS decfsz fileD,1 ; goto showL retlw 00 showO bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11101001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010110' ; movwf GPIO call _10mS decfsz fileD,1 ; goto showO retlw 00 showE bsf status, rp0 ;Bank 1 movlw b'11111001' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00000000' ; movwf GPIO call _10mS bsf status, rp0 ;Bank 1 movlw b'11001011' ; movwf TRISIO ; bcf status, rp0 ;bank 0 movlw b'00010100' ; movwf GPIO call _10mS decfsz fileD,1 ; goto showE retlw 00 flicker movlw 10h movwf flickA ff bsf status, rp0 ;Bank 1 movlw b'11111111' ; movwf TRISIO ; bcf status, rp0 ;bank 0 call _1mS call _1mS decfsz flickA,1 goto ff retlw 00 Main clrf fileD call _1to19 ;show numbers 1 to 19 on display Maina bsf fileD,3 call show19 btfsc GPIO,3 ;will be zero when button pushed goto Maina movlw 10h movwf tempA Main19 bsf fileD,1 call show19 call flicker decfsz tempA,1 goto Main19 Main19a bsf fileD,3 call show19 btfss GPIO,3 ;button must be released to get past here goto Main19a call clr500mS movlw 01Fh movwf timerA Main18c bsf fileD,3 call show18 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main18 ;player has pushed button decfsz timerA,1 goto Main18c goto comp18 ;player has ended his turn (run out of time) Main18 movlw 10h movwf tempA Main18a movf tempA,0 movwf flickA bsf fileD,1 call show18 call flicker decfsz tempA,1 goto Main18a Main18b bsf fileD,3 call show18 btfss GPIO,3 ;button must be released to get past here goto Main18b call clr500mS movlw 01Fh movwf timerA Main17c bsf fileD,3 call show17 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main17 ;player has pushed button decfsz timerA,1 goto Main17c goto comp17 ;player has ended his turn (run out of time) Main17 movlw 10h movwf tempA Main17a movf tempA,0 movwf flickA bsf fileD,1 call show17 call flicker decfsz tempA,1 goto Main17a Main17b bsf fileD,3 call show17 btfss GPIO,3 ;button must be released to get past here goto Main17b call clr500mS movlw 01Fh movwf timerA Main16c bsf fileD,3 call show16 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main16 ;player has pushed button decfsz timerA,1 goto Main16c goto comp16 ;player has ended his turn (run out of time) Main16 movlw 10h movwf tempA Main16a movf tempA,0 movwf flickA bsf fileD,1 call show16 call flicker decfsz tempA,1 goto Main16a Main16b bsf fileD,3 call show16 btfss GPIO,3 ;button must be released to get past here goto Main16b call clr500mS movlw 01Fh movwf timerA Main15c bsf fileD,3 call show15 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main15 ;player has pushed button decfsz timerA,1 goto Main15c goto comp15 ;player has ended his turn (run out of time) Main15 movlw 10h movwf tempA Main15a movf tempA,0 movwf flickA bsf fileD,1 call show15 call flicker decfsz tempA,1 goto Main15a Main15b bsf fileD,3 call show15 btfss GPIO,3 ;button must be released to get past here goto Main15b call clr500mS movlw 01Fh movwf timerA Main14c bsf fileD,3 call show14 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main14 ;player has pushed button decfsz timerA,1 goto Main14c goto comp14 ;player has ended his turn (run out of time) Main14 movlw 10h movwf tempA Main14a movf tempA,0 movwf flickA bsf fileD,1 call show14 call flicker decfsz tempA,1 goto Main14a Main14b bsf fileD,3 call show14 btfss GPIO,3 ;button must be released to get past here goto Main14b call clr500mS movlw 01Fh movwf timerA Main13c bsf fileD,3 call show13 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main13 ;player has pushed button decfsz timerA,1 goto Main13c goto comp13 ;player has ended his turn (run out of time) Main13 movlw 10h movwf tempA Main13a movf tempA,0 movwf flickA bsf fileD,1 call show13 call flicker decfsz tempA,1 goto Main13a Main13b bsf fileD,3 call show13 btfss GPIO,3 ;button must be released to get past here goto Main13b call clr500mS movlw 01Fh movwf timerA Main12c bsf fileD,3 call show12 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main12 ;player has pushed button decfsz timerA,1 goto Main12c goto comp12 ;player has ended his turn (run out of time) Main12 movlw 10h movwf tempA Main12a movf tempA,0 movwf flickA bsf fileD,1 call show12 call flicker decfsz tempA,1 goto Main12a Main12b bsf fileD,3 call show12 btfss GPIO,3 ;button must be released to get past here goto Main12b call clr500mS movlw 01Fh movwf timerA Main11c bsf fileD,3 call show11 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main11 ;player has pushed button decfsz timerA,1 goto Main11c goto comp11 ;player has ended his turn (run out of time) Main11 movlw 10h movwf tempA Main11a movf tempA,0 movwf flickA bsf fileD,1 call show11 call flicker decfsz tempA,1 goto Main11a Main11b bsf fileD,3 call show11 btfss GPIO,3 ;button must be released to get past here goto Main11b call clr500mS movlw 01Fh movwf timerA Main10c bsf fileD,3 call show10 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main10 ;player has pushed button decfsz timerA,1 goto Main10c goto comp10 ;player has ended his turn (run out of time) Main10 movlw 10h movwf tempA Main10a movf tempA,0 movwf flickA bsf fileD,1 call show10 call flicker decfsz tempA,1 goto Main10a Main10b bsf fileD,3 call show10 btfss GPIO,3 ;button must be released to get past here goto Main10b call clr500mS movlw 01Fh movwf timerA Main9c bsf fileD,3 call show9 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main9 ;player has pushed button decfsz timerA,1 goto Main9c goto comp9 ;player has ended his turn (run out of time) Main9 movlw 10h movwf tempA Main9a movf tempA,0 movwf flickA bsf fileD,1 call show9 call flicker decfsz tempA,1 goto Main9a Main9b bsf fileD,3 call show9 btfss GPIO,3 ;button must be released to get past here goto Main9b call clr500mS movlw 01Fh movwf timerA Main8c bsf fileD,3 call show8 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main8 ;player has pushed button decfsz timerA,1 goto Main8c goto comp8 ;player has ended his turn (run out of time) Main8 movlw 10h movwf tempA Main8a movf tempA,0 movwf flickA bsf fileD,1 call show8 call flicker decfsz tempA,1 goto Main8a Main8b bsf fileD,3 call show8 btfss GPIO,3 ;button must be released to get past here goto Main8b call clr500mS movlw 01Fh movwf timerA Main7c bsf fileD,3 call show7 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main7 ;player has pushed button decfsz timerA,1 goto Main7c goto comp7 ;player has ended his turn (run out of time) Main7 movlw 10h movwf tempA Main7a movf tempA,0 movwf flickA bsf fileD,1 call show7 call flicker decfsz tempA,1 goto Main7a Main7b bsf fileD,3 call show7 btfss GPIO,3 ;button must be released to get past here goto Main7b call clr500mS movlw 01Fh movwf timerA Main6c bsf fileD,3 call show6 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main6 ;player has pushed button decfsz timerA,1 goto Main6c goto comp6 ;player has ended his turn (run out of time) Main6 movlw 10h movwf tempA Main6a movf tempA,0 movwf flickA bsf fileD,1 call show6 call flicker decfsz tempA,1 goto Main6a Main6b bsf fileD,3 call show6 btfss GPIO,3 ;button must be released to get past here goto Main6b call clr500mS movlw 01Fh movwf timerA Main5c bsf fileD,3 call show5 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main5 ;player has pushed button decfsz timerA,1 goto Main5c goto comp5 ;player has ended his turn (run out of time) Main5 movlw 10h movwf tempA Main5a movf tempA,0 movwf flickA bsf fileD,1 call show5 call flicker decfsz tempA,1 goto Main5a Main5b bsf fileD,3 call show5 btfss GPIO,3 ;button must be released to get past here goto Main5b call clr500mS movlw 01Fh movwf timerA Main4c bsf fileD,3 call show4 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main4 ;player has pushed button decfsz timerA,1 goto Main4c goto comp4 ;player has ended his turn (run out of time) Main4 movlw 10h movwf tempA Main4a movf tempA,0 movwf flickA bsf fileD,1 call show4 call flicker decfsz tempA,1 goto Main4a Main4b bsf fileD,3 call show4 btfss GPIO,3 ;button must be released to get past here goto Main4b call clr500mS movlw 01Fh movwf timerA Main3c bsf fileD,3 call show3 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main3 ;player has pushed button decfsz timerA,1 goto Main3c goto comp3 ;player has ended his turn (run out of time) Main3 movlw 10h movwf tempA Main3a movf tempA,0 movwf flickA bsf fileD,1 call show3 call flicker decfsz tempA,1 goto Main3a Main3b bsf fileD,3 call show3 btfss GPIO,3 ;button must be released to get past here goto Main3b call clr500mS movlw 01Fh movwf timerA Main2c bsf fileD,3 call show2 call _1mS btfss GPIO,3 ;will be zero when button pushed goto Main2 ;player has pushed button decfsz timerA,1 goto Main2c goto Main1c ;player has ended his turn (run out of time) Main2 movlw 10h movwf tempA Main2a movf tempA,0 movwf flickA bsf fileD,1 call show2 call flicker decfsz tempA,1 goto Main2a Main2b bsf fileD,3 call show2 btfss GPIO,3 ;button must be released to get past here goto Main2b call clr500mS bsf fileD,7 call show1 call clr500mS bsf fileD,6 call showO call clr500mS goto Main Main1c clrf fileD call clr500mS bsf fileD,4 call show1 call clr500mS bsf fileD,4 call show1 call clr500mS bsf fileD,4 call show1 call clr500mS call clr500mS bsf fileD,4 call showU call clr500mS bsf fileD,4 call showL call clr500mS bsf fileD,4 call showO call clr500mS bsf fileD,4 call show5 call clr500mS bsf fileD,4 call showE call clr500mS call clr500mS goto Main comp18 call clr500mS bsf fileD,6 call show17 call clr500mS goto Main16c comp17 call clr500mS goto Main16c comp16 call clr500mS bsf fileD,6 call show15 call clr500mS bsf fileD,6 call show14 call clr500mS goto Main13c comp15 call clr500mS bsf fileD,6 call show14 call clr500mS goto Main13c comp14 call clr500mS goto Main13c comp13 call clr500mS goto Main12c comp12 call clr500mS bsf fileD,6 call show11 call clr500mS bsf fileD,6 call show10 call clr500mS goto Main9c comp11 call clr500mS bsf fileD,7 call show10 call clr500mS goto Main9c comp10 call clr500mS goto Main9c comp9 call clr500mS goto Main8c comp8 call clr500mS bsf fileD,6 call show7 call clr500mS bsf fileD,6 call show6 call clr500mS goto Main5c comp7 call clr500mS bsf fileD,6 call show6 call clr500mS goto Main5c comp6 call clr500mS goto Main5c comp5 call clr500mS goto Main4c comp4 call clr500mS bsf fileD,6 call show3 call clr500mS bsf fileD,6 call show2 goto Main1c comp3 call clr500mS bsf fileD,6 call show2 goto Main1c ;oscillator calibration call 03ffh movwf OSCCAL end