#INCLUDE”P16F877.inc”
W_TEMP EQU 20H ; 实际上20H、A0H、120H和1A0HSTATUS_TEMP EQU 21H ;在体0中树立维护单元 PCLATH_TEMP EQU 22H ;在体0中树立维护单元ORG 000HGOTO A1ORG 004H;守时中止进口地址 GOTO ZD01;ORG 0CHA1 MOVLW 1;位1显现数MOVWF 5AH; MOVLW 2;位2显现数MOVWF 5BH;MOVLW 3;位3显现数MOVWF 5CH;MOVLW 4;位4显现数MOVWF 5DH;MOVLW 4;显现位数MOVWF 40H;MOVLW B00000001;位码MOVWF 41H;MOVLW 5AH;MOVWF FSR ;直接寻址BSF STATUS,RP0;挑选体1BCF STATUS,RP1;MOVLW 00H;1:2TMRO份额MOVWF OPTION_REG;分频1/2BCF STATUS,RP0;体0BCF STATUS,RP1;MOVLW 0FFH;MOVFW TMR0;初值BCF INTCON,T0IF;清守时中止标志BSF INTCON,T0IE;开守时中止BSF INTCON,GIE;开总中止A2 CALL CL0;将16进制数调整为5位10进制数NOP;NOP;MOVFW 50HMOVWF 5AHMOVFW 51HMOVWF 5BHMOVFW 52HMOVWF 5CHMOVFW 53HMOVWF 5DHGOTO A2CL0 ; MOVLW 0H ;要显现16进制数低位; MOVWF 50H;; MOVLW 00H;; MOVWF 51H;要显现16进制数高位CALL CL1MOVLW B00001111ANDWF 54H,0MOVWF 50HMOVLW B11110000ANDWF 54H,1SWAPF 54H,0MOVWF 51HMOVFW 52HMOVWF 54HMOVLW B00001111ANDWF 53H,0MOVWF 52HMOVLW B11110000ANDWF 53H,1SWAPF 53H,1RETURNCL1 MOVLW 0;MOVWF 52H;万位MOVWF 53H;百千位MOVWF 54H;个十位MOVWF 55H;进位标志MOVLW 10H;MOVWF 56H;循环次数CLRF 57H;CL2 BCF STATUS,C;清CRLF 51H,1;循环左移RLF 50H,1;循环左移BTFSC STATUS,C;判别C位是否为高BSF 55H,0;是置1MOVFW 54H;ADDWF 55H,0;PIC没有ADDC指令只能判别C来加1ADDWF 54H,0;与本身相加BTFSC STATUS,C;判别是否有进位BSF 57H,7;有则置标志BTFSC STATUS,DC;判别是否有进位BSF 57H,3;有则置标志CALL DA1;调用十进制调整子程序MOVWF 54H;存回54HCLRF 55H;清进位标志BTFSC STATUS,C;判别C位是否为高BSF 55H,0;是置1MOVFW 53H;ADDWF 55H,0;PIC没有ADDC指令只能判别C来加1ADDWF 53H,0;与本身相加BTFSC STATUS,C;BSF 57H,6;BTFSC STATUS,DC;判别是否有进位BSF 57H,2;有则置标志CALL DA1;MOVWF 53H;CLRF 55H ;BTFSC STATUS,C;BSF 55H,0;MOVFW 52H;ADDWF 55H,0;ADDWF 52H,0;BTFSC STATUS,C;BSF 57H,5;BTFSC STATUS,C;判别是否有进位BSF 57H,1;有则置标志CALL DA1;MOVWF 52H;CLRF 55H;BTFSS 57H,7;判别标志是否有进位GOTO CL03;否INCF 53H,1;是进位MOVLW 60H;ADDWF 54H,1;本身加60H CL03 BTFSS 57H,3;判别标志是否有进位GOTO CL3;否MOVLW 6H;ADDWF 54H,1;本身加6H CL3 BTFSS 57H,6;判别标志是否有进位GOTO CL04;INCF 52H,1;是进位MOVLW 60H;ADDWF 53H,1;本身加60H CL04 BTFSS 57H,2;判别标志是否有进位GOTO CL4;否MOVLW 6H;ADDWF 53H,1;本身加6H CL4 BTFSS 57H,5;判别标志是否有进位GOTO CL05;INCF 51H,1;是进位MOVLW 60H;ADDWF 52H,1;本身加60H CL05 BTFSS 57H,1;判别标志是否有进位GOTO CL5;否MOVLW 6H;ADDWF 52H,1;本身加6HCL5 CLRF 57H;清标志DECFSZ 56H,1;GOTO CL2;RETURN;