INC TCNT MOV A,TCNT CJNE A,#20,RETUNE ; 计时 1秒 INC SECOND MOV TCNT,#0 MOV A,SECOND CJNE A,#60,RETUNE INC MINUTE MOV SECOND,#0 MOV A,MINUTE CJNE A,#60,RETUNE INC HOUR MOV MINUTE,#0 MOV A,HOUR CJNE A,#24,RETUNE MOV HOUR,#0 MOV MINUTE,#0 MOV SECOND,#0 MOV TCNT,#0 RETUNE: RETI DISPLAY: MOV A,SECOND ; 显示秒 MOV B,#10 DIV AB CLR P3.6 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.6 MOV A,B CLR P3.7 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.7 CLR P3.5 MOV P0,#40H ; 显示分隔符 LCALL DELAY SETB P3.5 MOV A,MINUTE ; 显示分钟 MOV B,#10 DIV AB CLR P3.3 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.3 MOV A,B CLR P3.4 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.4 CLR P3.2 MOV P0,#40H ; 显示分隔符 LCALL DELAY SETB P3.2 MOV A,HOUR ; 显示小时 MOV B,#10 DIV AB CLR P3.0 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.0 MOV A,B CLR P3.1