單片機(jī)60S倒計時匯編語言
AJMP MAIN
ORG 000BH
AJMP INTT0
ORG 0030H
MAIN: MOV R7,#60
MOV R6,#00H
MOV DPTR,#TABLE
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH ;設(shè)置定時器工作方式、初值
SETB EA
SETB ET0
SETB TR0
NEXT: MOV A,R7
MOV B,#0AH
DIV AB
SETB P1.3
MOVC A,@A+DPTR
MOV P0,A
CLR P1.4 ;開啟shi位顯示
ACALL DELAY
MOV A,B
SETB P1.4
MOVC A,@A+DPTR
MOV P0,A
CLR P1.3 ;開啟ge位顯示
ACALL DELAY
CJNE R6,#14H,NEXT
MOV R6,#00H
DEC R7
CJNE R7,#0FFH,NEXT
SJMP MAIN
INTT0:MOV TL0,#0B0H ;中斷服務(wù)程序
MOV TH0,#3CH
INC R6
RETI
DELAY:MOV R5,#02H ;延時子程序
LOOP:MOV R4,#02H
DJNZ R4,$
DJNZ R5,LOOP
RET
TABLE:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
評論