;---------------------------------------; ; Hodiny v23 ; ;---------------------------------------; ; slovak@post.cz )S(01.2010 ; ;---------------------------------------; ; Xtal = 4194304Hz LIST P=16F628A, R=DEC, MM=ON ;direktivy prekladace include ;definice nazvu registru __CONFIG 0x3F41 ;konfigurace ; CP=OFF,WDog=OFF,Put=ON,OSC=XT,MCLRE=I/O cblock 0x20 Mem_Stat Fl ;priznaky D256 ;delic 256/256=1Hz D3 ;děloč 256/3=85,3Hz Tecky ;deesetine tecky 0=sviti Pozice ;číslo zapnutého displeje Anody ;anody 1=sviti Katody ;katody segmentu displeje 0=sviti Dis0 ;displej cislo 0 prvni zprava Dis1 ;displej cislo 1 Dis2 ;displej cislo 2 Dis3 ;displej cislo 3 CMOD ;cislo modu 0az11 - mod 1az4 Sek ;Sekundy 0-59 Min ;Minuty 0-59 Hod ;Hodiny 0-23 CDDR ;>9=Rok >7=Dny >5=Datum ostatni=Hodiny PoNe ;den v tydnu Pondeli_0 az Nedele_6 Den ;Den 1 az 31 Mes ;Mesic 1 az 12 Rok ;Rok 0 az 99 MAXden ;max den podle mesice Kdel ;delic pro opakovani KLV R1 ;rad jednicek pro HEXDEC R10 ;rad desitek pro HEXDEC BLIK ;delic pro blikani displeje PJAS ;pamet jasu RJAS ;regulace jasu DKLV ;delic pro cteni KLV KLVP ;KLV port, stisknute tlacitko =0 PKJS ;Progresivní KJS endc Mem_W EQU 0x7F #define Stisk Fl,0 ;1=stisknuta klavesa #define Znova Fl,1 ;1=delsi stisk KLV #define EMes Fl,6 ;1=uplynul mesic #define Tec Tecky,0 ;tecka vpravo xx xx.(0=svítí) #define TVt Tecky,2 ;tecka vterin xx.xx #define TJa Tecky,1 ;tecka pro jas xx x.x #define TlN KLVP,0 ;bit0 pin6 tlacitko Nastavit #define TlZ KLVP,1 ;bit1 pin7 tlacitko Zmenit #define Utest PORTA,4 ;bit4 pin3 vstup pro test napajeni (0=vyp) ;================================ ; kod programu ;-------------------------------- ORG 0 GOTO Start ; skok na zacatek programu CALL 41 CALL 83 CALL 40 GOTO IntProc ; skok na obsluhu preruseni ;================================ ; podprogramy ;-------------------------------- ;prevod cislo znaku/sedmisegment SEGMENT MOVWF R10 ; SUBLW 0x24 ;24-Seg MOVF R10,W ;puvodni znak BTFSS STATUS,C ;kladne? MOVLW 0x20 ;NE, nahradit znak ADDWF PCL,F ;ANO RETLW 0xC0 ;0x00/0 RETLW 0xF9 ;0x01/1 RETLW 0xA4 ;0x02/2 RETLW 0xB0 ;0x03/3 RETLW 0x99 ;0x04/4 RETLW 0x92 ;0x05/5 RETLW 0x82 ;0x06/6 RETLW 0xF8 ;0x07/7 RETLW 0x80 ;0x08/8 RETLW 0x90 ;0x09/9 RETLW 0x88 ;0x0A/A RETLW 0x83 ;0x0B/b RETLW 0xC6 ;0x0C/C RETLW 0xA1 ;0x0D/d RETLW 0x86 ;0x0E/E RETLW 0x8E ;0x0F/F RETLW 0x89 ;0x10/H RETLW 0xEF ;0x11/i RETLW 0xE1 ;0x12/J RETLW 0x9A ;0x13/S RETLW 0xC7 ;0x14/L RETLW 0xC8 ;0x15/M RETLW 0xAB ;0x16/n RETLW 0xA3 ;0x17/o RETLW 0x8C ;0x18/P RETLW 0xAF ;0x19/r RETLW 0x87 ;0x1A/t RETLW 0xE3 ;0x1B/u RETLW 0xC1 ;0x1C/V RETLW 0x8D ;0x1D/Y RETLW 0xBF ;0x1E/- RETLW 0xB9 ;0x1F/-1 RETLW 0xFF ;0x20/ (vypnuty znak) RETLW 0xB7 ;0x21/= RETLW 0xB6 ;0x22/. (-30) RETLW 0xA7 ;0x23/c RETLW 0xF0 ;0x24/) ;-------------------------------- PoNe1 MOVF PoNe,W ADDWF PCL,F RETLW 0x18 ;P RETLW 0x1C ;U RETLW 0x05 ;S RETLW 0x0C ;C RETLW 0x18 ;P RETLW 0x05 ;S RETLW 0x16 ;n PoNe2 MOVF PoNe,W ADDWF PCL,F RETLW 0x17 ;o RETLW 0x1A ;t RETLW 0x1A ;t RETLW 0x1A ;t RETLW 0x0A ;A RETLW 0x17 ;o RETLW 0x0E ;E PoNe3 MOVF PoNe,W ADDWF PCL,F RETLW 0x16 ;n RETLW 0x0E ;E RETLW 0x19 ;r RETLW 0x1B ;u RETLW 0x1A ;t RETLW 0x0B ;b RETLW 0x0D ;d PoNe4 MOVF PoNe,W ADDWF PCL,F RETLW 0x0D ;d RETLW 0x19 ;r RETLW 0x0E ;E RETLW 0x19 ;r RETLW 0x0E ;E RETLW 0x17 ;o RETLW 0x0E ;E ;-------------------------------- MaxDen MOVF Mes,W ADDWF PCL,F NOP RETLW 31 ;leden RETLW 28 ;unor RETLW 31 ;brezen RETLW 30 ;duben RETLW 31 ;kveten RETLW 30 ;cerven RETLW 31 ;cervenec RETLW 31 ;srpen RETLW 30 ;zari RETLW 31 ;rijen RETLW 30 ;listopad RETLW 31 ;prosinec ;-------------------------------- ;vybrat anodu ANODA MOVF Pozice,W ANDLW B'00000011' ADDWF PCL,F RETLW B'00000001' ;Dis0 (vpravo) RETLW B'00000010' ;Dis1 RETLW B'00000100' ;Dis2 RETLW B'00001000' ;Dis3 (vlevo) ;-------------------------------- ;prevod HEX/DEC, vstup W, vystup R1=jednicky, R10=W=desitky HEXDEC MOVWF R1 ; CLRF R10 ;=0 Rad10 MOVLW 10 ;vypocet radu desitek SUBWF R1,W ;-10 BTFSS STATUS,C ;kladne? GOTO End10 ;NE, hotovo MOVWF R1 ;ulozit rad jednicek INCF R10,F ;+1 GOTO Rad10 ;zpet End10 MOVF R10,W ;rad desitek RETURN ;-------------------------------- ;test KLV+opakovani, sZ=0=neco stisknuto, sZ=1=zadne tlacitko KLV MOVF KLVP,W ANDLW 0x03 ;00000011 1a1=1 XORLW 0x03 ;00000011 st.=0 BTFSS STATUS,Z ;=1?, nenulove? (zadne tlacitko) GOTO Neco ;NE BCF Stisk ;=0 BSF Znova ;=1 RETURN Neco BSF STATUS,Z ;sZ=1 BTFSS Znova ;=1?, odcasovano? RETURN ;NE, jako zadne tl. MOVLW 0x0A ;kratsi cas (0.1s) BTFSS Stisk ;=1?, minule stisknuto? MOVLW 0x64 ;delsi cas (1s) MOVWF Kdel ;nastavit cas BCF Znova ;=0 BSF Stisk ;=1 CLRF BLIK ;od znova BCF STATUS,Z ;=0 RETURN ;-------------------------------- SEKUNDA ;CDDR+1 INCF CDDR,F ;+1 MOVF CDDR,W SUBWF CMOD,W ;CMOD-CDDR BTFSS STATUS,C ;C=1? kladne CLRF CDDR ;=0 ;zap mod hodin MOVF Sek,W SUBLW 55 BTFSC STATUS,Z CLRF CDDR ;sekundy+1 INCF Sek,F ;+1 MOVF Sek,W SUBLW 59 ;59-Sek BTFSC STATUS,C ;C=0? zaporne RETURN ;NE CLRF Sek ;=0 ;minuty+1 INCF Min,F ;+1 MOVF Min,W SUBLW 59 ;59-Min BTFSC STATUS,C ;C=0? zaporne RETURN ;NE CLRF Min ;=0 ;hodiny+1 INCF Hod,F ;+1 ;automaticka zmena jasu MOVF Hod,W SUBLW 6 ;v 6.00 BTFSS STATUS,Z GOTO $+3 MOVLW 5 ;JAS.5 MOVWF PJAS MOVF Hod,W SUBLW 8 ;v 8.00 BTFSS STATUS,Z GOTO $+3 MOVLW 9 ;JAS.9 MOVWF PJAS MOVF Hod,W SUBLW 18 ;v 18.00 BTFSS STATUS,Z GOTO $+3 MOVLW 4 ;JAS.4 MOVWF PJAS MOVF Hod,W SUBLW 20 ;v 20.00 BTFSS STATUS,Z GOTO $+3 MOVLW 0 ;JAS.0 MOVWF PJAS ;dokonceni hodiny+1 MOVF Hod,W SUBLW 23 ;23-Hod BTFSC STATUS,C ;C=0? zaporne RETURN CLRF Hod ;ANO;=0 ;dny v tydnu+1 INCF PoNe,F ;+1 MOVF PoNe,W SUBLW 6 ;6-PoNe BTFSS STATUS,C ;C=1? kladne CLRF PoNe ;NE;=0 ;dny+1 INCF Den,F ;+1 MOVF Den,W SUBWF MAXden,W ;MAXden-Den BTFSC STATUS,C ;C=0? zaporne RETURN MOVLW 1 ;ANO MOVWF Den ;=1 ;mesic+1 BSF EMes INCF Mes,F ;+1 MOVF Mes,W SUBLW 12 ;12-Mesic BTFSC STATUS,C ;C=0?; zaporne RETURN MOVLW 1 ;ANO MOVWF Mes ;=1 ;rok+1 INCF Rok,F ;+1 MOVF Rok,W SUBLW 99 ;99-Rok BTFSS STATUS,C ;C=1?; kladne CLRF Rok ;NE;=0 RETURN ;================================ ; preruseni 256Hz ;-------------------------------- IntProc MOVWF Mem_W SWAPF STATUS,W CLRF STATUS MOVWF Mem_Stat ;-------------------------------- ;obsluha displeje ;zhasnout displej CLRF PORTA ;VYP displej ;test napajeni BTFSS Utest ;napajeni? GOTO RJ ;NE ;delic pro cteni KLV 256/13=20Hz DECFSZ DKLV,F ;-1=0? GOTO NKLV ;NE MOVLW 13 ;znovu MOVWF DKLV ; naplnit ;cteni KLV MOVLW 0xFF ;11111111 MOVWF PORTB ;vystupy PB=1 BSF STATUS,RP0 ;Banka1 MOVWF TRISB ;1=vstupy BCF STATUS,RP0 ;Banka0 MOVF PORTB,W ;cteni KLV MOVWF KLVP ;ulozit KLV BSF STATUS,RP0 ;Banka1 CLRF TRISB ;0=vystupy BCF STATUS,RP0 ;Banka0 GOTO RJ NKLV NOP ;nahrada NOP ;misto cteni KLV NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; NOP ; ;regulace jasu RJ MOVLW 9 SUBWF RJAS,W ;RJAS-9 BTFSC STATUS,C ;záporné? C=0 GOTO KJS ;NE ;cekat (395 cyklu, 377us) MOVLW 165 ;(158) ADDLW 1 ;1+W BTFSS STATUS,Z ;=0? GOTO $-2 ;NE, znova INCF RJAS,F ;RJAS+1 GOTO RJ ;korekce jasu segmentu ;)S(01.2010 KJS BTFSC Katody,0 ;=0?, segment svítí? CALL KJSZ ;NE, zpozdění BTFSC Katody,1 CALL KJSZ BTFSC Katody,2 CALL KJSZ BTFSC Katody,3 CALL KJSZ BTFSC Katody,4 CALL KJSZ BTFSC Katody,5 CALL KJSZ BTFSC Katody,6 CALL KJSZ BTFSC Katody,7 CALL KJSZ ;rosvitit displej ZAPD MOVF Katody,W ;nove katody MOVWF PORTB ; MOVF Anody,W ;nove anody MOVWF PORTA ;ZAP displej MOVF PJAS,W ;znovu MOVWF RJAS ; naplnit ;-------------------------------- ;priprava pro pristi zobrazeni ;nova pozice INCF Pozice,f ;zvetsit pozici, dalsi znak MOVLW B'00000011' ;celkem 4 místa (0-3) ANDWF Pozice,f ;bity 7-2 odseknout ;anody podle pozice CALL ANODA MOVWF Anody ;test napajeni BTFSC Utest ;napajeni? GOTO VK ;ANO ;neni napajeni MOVLW 0xFF ;VYP znak MOVWF Katody ; CLRF PJAS ;nejmenší jas ;blikat TVt, ostatni VYP BSF Tec ;VYP BSF TJa ;VYP BTFSC D256,7 ;=0? BCF TVt ;ZAP tecku vterin BTFSS D256,7 ;=1? BSF TVt ;VYP tecku vterin GOTO PT ;katody podle pozice VK MOVLW Dis0 ;cislo adresy RAM, nikoliv obsah MOVWF FSR ; do FSR, ukazovatko (pointer) MOVF Pozice,W ;cislo zapnuteho displeje (0 az 3) ADDWF FSR,f ;FSR+pozice=FSR MOVF INDF,W ;nacist znak z mista, na ktery odkazuje FSR MOVWF Katody ;nove katody ;pridat tecku PT MOVF Anody,W ANDWF Tecky,W ;1a1=1 test BTFSC STATUS,Z ;Z=0? tecka=1 BCF Katody,7 ;bit7=0=zap tecku ;-------------------------------- ;delic 256/256=1Hz INCF D256,F ;+1 BTFSC STATUS,Z ;preteklo? CALL SEKUNDA ;ANO ;-------------------------------- ;delic pro blikani displeje INCF BLIK,F ;+1 ;-------------------------------- ;delic 256/2=85,3Hz DECFSZ D3,F ;-1=0? GOTO EInt MOVLW 3 MOVWF D3 ;delic pro opakovani KLV DECFSZ Kdel,F ;-1,=0? GOTO $+2 BSF Znova ;=1 ;-------------------------------- ;konec preruseni EInt BCF INTCON,T0IF ;nulovat priznak TMR0 SWAPF Mem_Stat,W MOVWF STATUS SWAPF Mem_W,F SWAPF Mem_W,W RETFIE ;navrat z preruseni ;-------------------------------- ;zpozdění pro KJS ;................................ ;katodové rezistory R1 až R8 = 120 ohm ;................................ KJSZ BCF STATUS,C ;Progresivní nastavení podle jasu RLF PJAS,W ;Jas*8 MOVWF PKJS ; RLF PKJS,F ; RLF PKJS,W ; =W SUBLW 240 ;240-W časování ADDLW 1 ;1+W BTFSS STATUS,Z ;=0? GOTO $-2 ;NE, znova RETURN ;================================ ;hlavni program ;-------------------------------- Start ;inicializace procesoru MOVLW 0x07 ;OFF MOVWF CMCON ; Comparators BSF STATUS,RP0 ;Banka1 MOVLW B'00000011' ;1:16 MOVWF OPTION_REG ; MOVLW B'11110000' ;1=vstup, 0=vystup MOVWF TRISA ;PA vystupy mimo A4 CLRF TRISB ;PB vystupy BCF STATUS,RP0 ;Banka0 CLRF PORTA ;00000000 CLRF Fl CLRF Pozice MOVLW 9 MOVWF PJAS MOVLW 11 MOVWF CMOD MOVLW 0xFF MOVWF KLVP MOVWF Tecky CLRF Sek CLRF Min CLRF Hod CLRF PoNe MOVLW 3 MOVWF Den MOVLW 8 MOVWF Mes BSF EMes MOVLW 9 MOVWF Rok MOVLW B'10100000' ;preruseni od TMR0 MOVWF INTCON ; ;-------------------------------- ;prvni Den Datum Rok PHODINY MOVLW 4 MOVWF CDDR GOTO HODINY PDATUM MOVLW 6 MOVWF CDDR CALL MaxDen MOVWF MAXden GOTO DATUM PDNY MOVLW 8 MOVWF CDDR GOTO DNY PROK MOVLW 10 MOVWF CDDR GOTO ROK ;-------------------------------- ;prepinac Den Datum Rok PDDR MOVF CDDR,W SUBLW 9 BTFSS STATUS,C ;C=1? kladne GOTO ROK MOVF CDDR,W SUBLW 7 BTFSS STATUS,C ;C=1? kladne GOTO DNY MOVF CDDR,W SUBLW 5 BTFSS STATUS,C ;C=1? kladne GOTO DATUM ;-------------------------------- ;mod hodiny HODINY BSF Tec ;vyp BSF TJa ;vyp BTFSS EMes GOTO HODINYS CALL MaxDen MOVWF MAXden BCF EMes HODINYS MOVF Hod,W ;hodiny CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis3 ;Hod desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Hod jednicky MOVF Min,W ;minuty CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;Min desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Min jednicky BTFSS D256,7 BCF TVt ;zap tecku vterin BTFSC D256,7 BSF TVt ;vyp tecku vterin CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO PDDR ;NE BTFSC TlN ;stisknuto? GOTO ZMOD ;NE ;-------------------------------- ;nastavit hodiny BSF TVt ;vyp MOVLW 0x80 MOVWF BLIK BLHOD BTFSS BLIK,7 GOTO BLHODH MOVLW 0xFF ;zadny znak MOVWF Dis3 ;vyp Hod desitky MOVWF Dis2 ;vyp Hod jednicky GOTO BLHODM BLHODH MOVF Hod,W ;hodiny CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis3 ;Hod desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Hod jednicky BLHODM MOVF Min,W ;minuty CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;Min desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Min jednicky BLHODIN CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLHOD ;NE BTFSS TlN ;stisknuto? GOTO NMIN ;ANO ;-------------------------------- ;Hod+1 INCF Hod,F ;Hod+1 MOVF Hod,W SUBLW 23 ;23-Hod BTFSS STATUS,C ;C=1? kladne CLRF Hod ;NE;=0 GOTO BLHOD ;-------------------------------- ;nastavit minuty NMIN BSF TVt ;vyp MOVLW 0x80 MOVWF BLIK BLMIN MOVF Hod,W ;hodiny CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis3 ;Hod desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Hod jednicky BTFSS BLIK,7 GOTO BLMINM MOVLW 0xFF MOVWF Dis1 MOVWF Dis0 GOTO BLMINUT BLMINM MOVF Min,W ;minuty CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;Min desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Min jednicky BLMINUT CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLMIN ;NE BTFSS TlN ;stisknuto? GOTO NSEK ;ANO ;-------------------------------- ;Min+1 INCF Min,F ;Min+1 MOVF Min,W SUBLW 59 ;59-Min BTFSS STATUS,C ;C=1? kladne CLRF Min ;NE;=0 GOTO BLMIN ;-------------------------------- ;mod sekundy NSEK BCF TVt ;zap MOVLW 0x05 ;znak S CALL SEGMENT MOVWF Dis3 MOVLW 0x0E ;znak E CALL SEGMENT MOVWF Dis2 MOVF Sek,W ;seundy CALL HEXDEC CALL SEGMENT MOVWF Dis1 MOVF R1,W CALL SEGMENT MOVWF Dis0 CALL KLV BTFSC STATUS,Z GOTO NSEK BTFSS TlN GOTO PHODINY ;-------------------------------- ;sekunda od nuly CLRF D256 CLRF Sek BSF Znova GOTO NSEK ;-------------------------------- ;mod dny DNY BSF Tec ;vyp BSF TVt ;vyp CALL PoNe1 CALL SEGMENT MOVWF Dis3 CALL PoNe2 CALL SEGMENT MOVWF Dis2 CALL PoNe3 CALL SEGMENT MOVWF Dis1 CALL PoNe4 CALL SEGMENT MOVWF Dis0 CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO PDDR ;NE BTFSC TlN ;stisknuto? GOTO ZMOD ;NE ;-------------------------------- ;nastavit PoNe MOVLW 0x80 MOVWF BLIK BLPONE BTFSS BLIK,7 GOTO BLPONEZAP MOVLW 0xFF ;zadny znak MOVWF Dis3 ;vyp MOVWF Dis2 ; MOVWF Dis1 ; MOVWF Dis0 ; GOTO BLPONEDNY BLPONEZAP CALL PoNe1 CALL SEGMENT MOVWF Dis3 CALL PoNe2 CALL SEGMENT MOVWF Dis2 CALL PoNe3 CALL SEGMENT MOVWF Dis1 CALL PoNe4 CALL SEGMENT MOVWF Dis0 BLPONEDNY CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLPONE ;NE BTFSS TlN ;stisknuto? GOTO PDNY ;ANO ;-------------------------------- ;PoNe+1 INCF PoNe,F MOVF PoNe,W SUBLW 6 ;6-PoNe BTFSS STATUS,C ;C=1? kladne CLRF PoNe ;=0 GOTO BLPONE ;-------------------------------- ;mod Datum DATUM BCF Tec ;zap BCF TVt ;zap MOVF Den,W CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis3 ;Den desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Den jednicky MOVF Mes,W CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis1 ;Mesic desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Mesic jednicky CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO PDDR ;NE BTFSC TlN ;stisknuto? GOTO ZMOD ;NE ;-------------------------------- ;nastavit Dny MOVLW 0x80 MOVWF BLIK BLNDNY BTFSS BLIK,7 GOTO BLDNYZAP MOVLW 0xFF ;zadny znak MOVWF Dis3 ;vyp Dny desitky MOVWF Dis2 ;vyp Dny jednicky BSF TVt ;vyp GOTO BLDNY BLDNYZAP MOVF Den,W CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis3 ;Dny desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Dny jednicky BCF TVt ;zap BLDNY MOVF Mes,W CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis1 ;Mesic desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Mesic jednicky CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLNDNY ;NE BTFSS TlN ;stisknuto? GOTO NMESIC ;ANO ;-------------------------------- ;Dny+1 INCF Den,F ;+1 MOVF Den,W SUBWF MAXden,W ;MAXden-Den BTFSC STATUS,C ;C=0? zaporne GOTO BLNDNY MOVLW 1 MOVWF Den GOTO BLNDNY ;-------------------------------- ;nastavit mesic NMESIC BCF TVt ;zap MOVLW 0x80 MOVWF BLIK BLNMESIC MOVF Den,W CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis3 ;Den desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Den jednicky BTFSS BLIK,7 GOTO BLMESICZAP MOVLW 0xFF ;zadny znak MOVWF Dis1 ;vyp Mesic desitky MOVWF Dis0 ;vyp Mesic jednicky BSF Tec ;vyp GOTO BLMESIC BLMESICZAP MOVF Mes,W CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis1 ;Mesic desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Mesic jednicky BCF Tec ;zap BLMESIC CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLNMESIC ;NE BTFSS TlN ;stisknuto? GOTO PDATUM ;ANO ;-------------------------------- ;Mesic+1 BSF EMes INCF Mes,F ;+1 MOVF Mes,W SUBLW 12 ;12-Mes BTFSC STATUS,C ;C=0? zaporne GOTO BLNMESIC MOVLW 1 MOVWF Mes GOTO BLNMESIC ;-------------------------------- ;mod rok ROK BSF Tec ;vyp BSF TVt ;vyp BSF TJa ;vyp MOVLW 2 ;2 CALL SEGMENT MOVWF Dis3 MOVLW 0 ;0 CALL SEGMENT MOVWF Dis2 MOVF Rok,W CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis1 ;Rok desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Rok jednicky CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO PDDR ;NE BTFSC TlN ;stisknuto? GOTO ZMOD ;NE ;-------------------------------- ;nastavit rok MOVLW 0x80 MOVWF BLIK BLNROK BTFSS BLIK,7 GOTO BLROKZAP MOVLW 0xFF ;zadny znak MOVWF Dis3 ;vyp MOVWF Dis2 ; MOVWF Dis1 ; MOVWF Dis0 ; GOTO BLROK BLROKZAP MOVLW 2 ;2 CALL SEGMENT MOVWF Dis3 MOVLW 0 ;0 CALL SEGMENT MOVWF Dis2 MOVF Rok,W CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis1 ;RoK desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;RoK jednicky BLROK CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLNROK ;NE BTFSS TlN ;stisknuto? GOTO JAS ;ANO ;-------------------------------- ;Rok+1 INCF Rok,F ;+1 MOVF Rok,W SUBLW 99 ;99-Rok BTFSS STATUS,C ;C=1? kladne CLRF Rok GOTO BLNROK ;-------------------------------- ;mod JAS JAS BCF TJa ;zap MOVLW 0x80 MOVWF BLIK MOVLW 0x12 ;J CALL SEGMENT MOVWF Dis3 MOVLW 0x0A ;A CALL SEGMENT MOVWF Dis2 MOVLW 0x05 ;S CALL SEGMENT MOVWF Dis1 BLJAS BTFSS BLIK,7 GOTO BLJASZ MOVLW 0xFF MOVWF Dis0 GOTO BLJASK BLJASZ MOVF PJAS,W CALL SEGMENT MOVWF Dis0 BLJASK CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLJAS ;NE BTFSS TlN ;stisknuto? GOTO PROK ;ANO ;-------------------------------- ;JAS+1 INCF PJAS,F ;+1 MOVF PJAS,W SUBLW 10 ;10-PJAS BTFSC STATUS,Z ; nenulove? CLRF PJAS ; =0 GOTO BLJAS ;-------------------------------- ;zmena modu ZMOD MOVF CMOD,W SUBLW 9 MOVF CMOD,W BTFSS STATUS,C MOVLW 3 ADDLW 2 MOVWF CMOD BSF Tec ;vyp BSF TVt ;vyp BSF TJa ;vyp MOVLW 0x15 ;M CALL SEGMENT MOVWF Dis3 MOVLW 0x17 ;o CALL SEGMENT MOVWF Dis2 MOVLW 0x0D ;d CALL SEGMENT MOVWF Dis1 MOVF CMOD,W SUBLW 11 MOVLW 4 ;4 BTFSC STATUS,Z GOTO EZMOD MOVF CMOD,W SUBLW 9 MOVLW 3 ;3 BTFSC STATUS,Z GOTO EZMOD MOVF CMOD,W SUBLW 7 MOVLW 2 ;2 BTFSS STATUS,Z MOVLW 1 ;1 EZMOD CALL SEGMENT MOVWF Dis0 SZMOD BTFSS TlZ GOTO SZMOD MOVLW 4 MOVWF CDDR GOTO PDDR ;-------------------------------- NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP GOTO Start ;-------------------------------- END ; konec programu