#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顯示數(shù)MOVWF 5AH; MOVLW 2;位2顯示數(shù)MOVWF 5BH;MOVLW 3;位3顯示數(shù)MOVWF 5CH;MOVLW 4;位4顯示數(shù)MOVWF 5DH;MOVLW 4;顯示位數(shù)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進制數(shù)調(diào)整為5位10進制數(shù)NOP;NOP;MOVFW 50HMOVWF 5AHMOVFW 51HMOVWF 5BHMOVFW 52HMOVWF 5CHMOVFW 53HMOVWF 5DHGOTO A2CL0 ; MOVLW 0H ;要顯示16進制數(shù)低位; MOVWF 50H;; MOVLW 00H;; MOVWF 51H;要顯示16進制數(shù)高位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;循環(huán)次數(shù)CLRF 57H;CL2 BCF STATUS,C;清CRLF 51H,1;循環(huán)左移RLF 50H,1;循環(huán)左移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;調(diào)用十進制調(diào)整子程序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;
評論