#INCLUDE”P16F877.inc”
ORG 000HGOTO A1ORG 04HGOTO ZD01A1 BSF STATUS,RP0BCF STATUS,RP1;体1MOVLW 0HMOVWF TRISA;设置A口为输出口MOVLW 06H MOVWF ADCON1;设置A口为一般I/O口形式 movlw 0FFHmovwf TRISB;设定RB为输入BCF STATUS,RP0BCF STATUS,RP1;体0MOVLW 0FFHMOVWF PORTA;A口输出高电平BCF INTCON,INTF;清中止标志BSF INTCON,INTE;开外部中止BSF INTCON,GIE;开总中止GOTO $ZD01 BTFSS INTCON,INTF;判别是否发生外部中止GOTO ZD02 BCF INTCON,INTF;清中止标志BTFSS PORTB,0;;判别触发中止键是否抬起防止发生2次中止GOTO $-1;COMF PORTA,1;取反A口ZD02 RETFIE ;中止标志END#INCLUDE"P16F877.inc"ORG 000HGOTO A1ORG 004H;守时中止进口地址 GOTO ZD01;ORG 0CHA1 MOVLW 1;位1显现数MOVWF 50H; MOVLW 2;位2显现数MOVWF 51H;MOVLW 3;位3显现数MOVWF 52H;MOVLW 4;位4显现数MOVWF 53H;MOVLW 4;显现位数MOVWF 40H;MOVLW B00000001;位码MOVWF 41H;MOVLW 50H;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 BTFSC PORTD,4GOTO A3MOVLW 1MOVWF 50HA3 BTFSC PORTD,5GOTO A4MOVLW 2MOVWF 50HA4 BTFSC PORTD,6GOTO A5MOVLW 3MOVWF 50HA5 BTFSC PORTD,7GOTO A6MOVLW 4MOVWF 50HA6 GOTO A2ZD01 BCF INTCON,GIE;关总中止BTFSS INTCON,T0IF;判别是否发生守时中止GOTO ZD03;否跳出是持续履行BCF INTCON,T0IFBSF STATUS,RP0;体1BCF STATUS,RP1;MOVLW 0;MOVWF TRISC;RB口设为输出口MOVLW B11110000MOVWF TRISD;RD口设为输出口BCF STATUS,RP0;体0BCF STATUS,RP1;MOVLW 0FFH;MOVWF PORTC;RB口输出高电平MOVLW 0MOVWF PORTD;RD口输出低电平起清屏效果MOVFW INDF;直接寻址显现数据 CALL Q1;查数据表MOVWF PORTC;显现断码输出到RB口INCF FSR,1;直接寻址地址加1MOVFW 41H ;位码MOVWF PORTD;位码输出到RD口RLF 41H,0;处理CRLF 41H,1;左移位码DECFSZ 40H,1;判别是否显现完4位GOTO ZD02;不然持续显现MOVLW 4;显现位数MOVWF 40H;MOVLW B00000001;位码MOVWF 41H;MOVLW 50H;MOVWF FSR ;直接寻址ZD02 MOVLW 0FFH;MOVFW TMR0;重装初值ZD03 BSF INTCON,GIE;开总中止RETFIE ;中止回来;********************************************; 数据表;******************************************** Q1 ADDWF PCL,1 RETLW 00C0H ;0RETLW 00F9H ;1RETLW 00A4H ;2RETLW 00B0H ;3RETLW 0099H ;4RETLW 0092H ;5RETLW 0082H ;6RETLW 00F8H ;7RETLW 0080H ;8RETLW 0090H ;9RETLW 0088H ;ARETLW 0083H ;BRETLW 00C6H ;CRETLW 00A1H ;DRETLW 0086H ;ERETLW 008EH ;FEND