说明以下的程序显示子程序(DISS)没有错误,主要是看看其他的. DI_DA DATA 20H MSEC DATA 21H SEC DATA 22H MIN DATA 23H HOUR DATA 24H HM DATA 25H /*定义的MSEC*/ MIAO DATA 26H /*定义的MIN*/ FEN DATA 27H /*定义的MIN*/ SHI DATA 28H /*定义的HOUR*/ ORG 0000H LJMP MAIN ORG 000BH AJMP ITOP ORG 0030H AJMP DDD *************************************************** MAIN: MOV SP,#40H MOV HM,#00H MOV MIAO,#00H MOV FEN,#00H MOV MSEC,HM /*MSEC是0.1S单元*/ MOV SEC,MIAO MOV MIN,FEN MOV SHI,#0F0H DDD: LCALL CLEAR /*清零*/ MOV TL0,#0B0H/*定时50MS*/ MOV TH0,#03CH MOV TMOD,#01H SETB TR0 SETB ET0 MOV DI_DA,#00H SETB EA ********************************************************** DISPLAY: ACALL CONV ACALL DISS AJMP DISPLAY ************************************************************ CONV: MOV A,DI_DA CJNE A,#02H,DONE /*0.1MS到否*/ MOV DI_DA,#00H MOV A,MSEC INC A MOV MSEC,A CJNE A,#0AH,DONE /*MSEC=0到*/ MOV MSEC,#00H MOV A,SEC INC A MOV SEC,A CJNE A,#0AH,DONE /*SEC=0*/ MOV SEC,#00H MOV A,MIN INC A MOV MIN,A CJNE A,#0AH,DONE MOV MIN,#00H CLR TR0 DONE: RET ********************************************************** DISS: MOV DPTR,#42H/*开始显示第一个数码管*/ MOV A,HM SWAP A MOV HM,A MOV A,#0FH ORL A,HM MOVX @DPTR,A MOV A,HM SWAP A MOV HM,A MOV A,#0FBH MOV DPTR,#40H MOVX @DPTR,A LCALL CLEAR2/*让第一个数码管灭*/ LCALL DEL11MS MOV DPTR,#TAB MOV A,MSEC MOVC A,@A+DPTR MOV DPTR,#42H MOVX @DPTR,A MOV DPTR,#40H MOV A,#0F7H MOVX @DPTR,A LCALL CLEAR2/*让第二个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*以上是显示MSEC*/ MOV DPTR,#42H MOV A,MIAO SWAP A MOV MIAO,A MOV A,#0FH ORL A,MIAO MOVX @DPTR,A MOV A,MIAO SWAP A MOV MIAO,A MOV A,#0FDH MOV DPTR,#40H MOVX @DPTR,A LCALL CLEAR2/*让第三个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*以上是显示MIAO*/ MOV A,SEC MOV DPTR,#TAB MOVC A,@A+DPTR MOV DPTR,#42H MOVX @DPTR,A MOV DPTR,#40H MOV A,#0FBH MOVX @DPTR,A LCALL CLEAR2/*让第四个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*以上是显示SEC*/ MOV DPTR,#42H MOV A,FEN SWAP A MOV FEN,A MOV A,#0FH ORL A,FEN MOVX @DPTR,A MOV A,FEN SWAP A MOV FEN,A MOV A,#0FEH MOV DPTR,#40H MOVX @DPTR,A LCALL CLEAR2 /*让第五个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*以上是显示FEN*/ MOV A,MIN MOV DPTR,#TAB MOVC A,@A+DPTR MOV DPTR,#42H MOVX @DPTR,A MOV DPTR,#40H MOV A,#0FDH MOVX @DPTR,A LCALL CLEAR2/*让第六个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*以上是显示MIN*/ MOV DPTR,#42H MOV A,SHI MOVX @DPTR,A MOV DPTR,#40H MOV A,#0FEH MOVX @DPTR,A LCALL CLEAR2/*让第七个数码管灭*/ LCALL DEL11MS LCALL CLEAR1/*显示SHI*/ RET ******************************************************** CLEAR2: MOV A,#00H /*数码管灭子程序*/ MOV DPTR, #41H MOVX @DPTR,A RET ********************************************************** CLEAR1: MOV A,#0FFH MOV DPTR,#40H MOVX @DPTR,A RET ********************************************************* TAB: DB 0F0H,0F1H,0F2H,0F3H,0F4H DB 0F5H,0F6H,0F7H,0F8H,0F9H ******************************************************** ITOP: PUSH ACC /*中断服务子程序*/ PUSH DPL PUSH DPH MOV TL0,#0B0H MOV TH0,#3CH MOV TMOD,#01H INC DI_DA POP DPH POP DPL POP ACC RETI ****************************************************** DEL11MS:NOP/*延时子程序*/ MOV R5,#01H LOOP2: MOV R7,#0AH AA: DJNZ R7,AA DJNZ R5,LOOP2 RET **************************************************** CLEAR: MOV A,#00H/*清零子程序*/ MOV DPTR,#041H MOVX @DPTR,A RET END
|