ORG 0000H
LJMP MAIN
ORG 0003H
LJMP EX0INT
ORG 0030H
MAIN:
MOV SP,#5FH
SETB IT0
SETB EX0
SETB EA
MOV R0,#0
MOV DPTR,#TABLE
MOV A,R0
MOVC A,@A+DPTR
MOV P2,A
LOOP:
MOV A,P1
CPL A
MOV P1,A
LCALL DELAY
SJMP LOOP
EX0INT:
PUSH ACC
INC R0
MOV DPTR,#TABLE
MOV A,R0
MOVC A,@A+DPTR
MOV P2,A
RETI
DELAY:
MOV R2,#100
DELAY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DELAY1
RET
TABLE: ; 共阴极数码管显示代码表
DB 0C0H,3FH,06H,5BH,4FH ;01234
DB 66H,6DH,7DH,07H,7FH ;56789
END