单片机汇编吧 关注:121贴子:364
  • 1回复贴,共1

动态显示时钟

只看楼主收藏回复

ORG 0000H
LJMP MAIN
ORG 000BH
LJMP TIME0
ORG 0100H
MAIN:
MOV SP,#60H ////////初始化//////
SETB ET0
SETB EA
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0 /////开启定时
MOV R7, #20
MOV 70H,#49H
MOV 71H,#59H
MOV 72H,#23H
LOOP:
LCALL DISPLAY
AJMP LOOP
DISPLAY:
MOV P1,#0FFH
////////////////////时显示/////
MOV A,72H
ANL A,#0FH
LCALL CHA
MOV P0,A
CLR P1.4
LCALL DELAY
SETB P1.4
MOV A,72H
ANL A,#0F0H
SWAP A
LCALL CHA
MOV P0,A
CLR P1.5
LCALL DELAY
SETB P1.5
/////////////////分显示//////
MOV A,71H
ANL A,#0FH
LCALL CHA
MOV P0,A
CLR P1.2
LCALL DELAY
SETB P1.2
MOV A,71H
ANL A,#0F0H
SWAP A
LCALL CHA
MOV P0,A
CLR P1.3
LCALL DELAY
SETB P1.3
////////////////秒显示//////
MOV A,70H
ANL A,#0FH
LCALL CHA
MOV P0,A
CLR P1.0
LCALL DELAY
SETB P1.0
MOV A,70H
ANL A,#0F0H
SWAP A
LCALL CHA
MOV P0,A
CLR P1.1
LCALL DELAY
SETB P1.1
RET
TIME0:
PUSH PSW
PUSH ACC
MOV TH0,#3CH
MOV TL0,#0B0H
DJNZ R7,OUT
MOV R7,#20
MOV A,70H
ADD A,#1
DA A
MOV 70H,A
CJNE A,#60H,OUT
MOV 70H,#00H
MOV A,71H
ADD A,#1
DA A
MOV 71H,A
CJNE A,#60H,OUT
MOV 71H,#00H
MOV A,72H
ADD A,#01H
DA A
MOV 72H,A
CJNE A,#24H,OUT
MOV 72H,#00H
OUT:
POP ACC
POP PSW
RETI
DELAY:
MOV R6,#50
DJNZ R6,$
RET
CHA:
MOV DPTR,#TAB
MOVC A,@A+DPTR
RET
TAB:
DB 3FH, 06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
END


IP属地:江西1楼2013-12-15 20:25回复
    有仿真图吗?没有很难看懂啊


    IP属地:广东来自Android客户端3楼2017-06-07 01:46
    回复