ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTX
MAIN:
MOV DPTR,#7FFFH
MOV R0,#0FFH
MOV A,R0
MOVX @DPTR,A
SETB EA
SETB EX0
L2:
MOV DPTR,#7FFFH
MOV A,R0
MOVX @DPTR,A
MOV TMOD ,#01H
MOV TL0,#00H
MOV TH0,#00H
MOV R1,#30H
JB P1.0,$
SETB TR0
JNB P1.0,$
CLR TR0
MOV @R1,TL0
INC R1
MOV @R1,TH0
LCALL ZH
LCALL DisplayLED
LJMP L2
ZH:
MOV A,30H
ANL A,#0FH
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV 32H,A
MOV A,30H
SWAP A
ANL A,#0FH
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV 33H,A
MOV A,31H
ANL A,#0FH
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV 34H,A
MOV A,31H
SWAP A
ANL A,#0FH
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV 35H,A
RET
LED:
DB 3FH,06H,5BH,4FH,66H,6DH
DB 7DH,07H,7FH,6FH,77H,7CH
DB 39H,5EH,79H,71H;
DisplayLED:
MOV A,35H
CLR P2.0
MOV P0,A
ACALL DELAY1
SETB P2.0
MOV A,34H
CLR P2.1
MOV P0,A
ACALL DELAY1
SETB P2.1
MOV A,33H
CLR P2.2
MOV P0,A
ACALL DELAY1
SETB P2.2
MOV A,32H
CLR P2.3
MOV P0,A
ACALL DELAY1
SETB P2.3
RET
DELAY1:
MOV R2,#20
D4: MOV R3,#250
DJNZ R3,$
DJNZ R2,D4
RET
INTX:
CLR EA
JNB P1.4,IN1
JNB P1.5,INT2
JNB P1.6,INT3
JNB P1.7,INT4
L1:
SETB EA
RETI
IN1:
MOV DPTR,#7FFFH
MOV R0,#80H
MOV A,R0
MOVX @DPTR,A
LCALL Delay
AJMP L1
INT2:
MOV DPTR,#7FFFH
CLR C
MOV A,#0F0H
SUBB A,R0
MOV R0,A
LCALL Delay
AJMP L1
INT3:
MOV DPTR,#7FFFH
MOV A,R0
INC A
MOV R0,A
MOVX @DPTR,A
LCALL Delay
AJMP L1
INT4:
MOV DPTR,#7FFFH
MOV A,R0
DEC A
MOV R0,A
MOVX @DPTR,A
LCALL Delay
AJMP L1
Delay: MOV R7, #02H; 延时子程序
DelayLoop1: MOV R6,#0FFH
DelayLoop2: MOV R5,#0FFH
DelayLoop3: DJNZ R5,DelayLoop3
DJNZ R6,DelayLoop2
DJNZ R7,DelayLoop1
RET
END
|