D1 BIT P3.0
D2 BIT P3.2
D3 BIT P3.3
DBUF EQU 35H
TEMP EQU 50H
DIN BIT P3.4
CLK BIT P3.5
ORG 0
LJMP START
ORG 000BH
中断程序
T0INT:
PUSH PSW
MOV TH0,#0DAH
MOV TL0,#80H
DJNZ R7,EXIT
MOV C,D2
JC QS ;选择速度
MS: MOV R7,#0F8H ; 慢
MOV DBUF+3,#4
MOV DBUF+2,#1
LJMP QQQ1
FX: MOV C,D3
JC SHX ;选择类型
DX: CLR C
MOV C,D1
JC ZY1
YY1: ;右移
MOV A,21H
RR A
MOV 21H,A
MOV P1,A
MOV DBUF+1,#2
MOV DBUF+0,#2
LJMP QQQ2
LJMP EXIT
ZY1: ;左移
MOV A,20H
RL A
MOV 20H,A
MOV P1,A
MOV DBUF+1,#4
MOV DBUF+0,#4
LJMP QQQ2
LJMP EXIT
SHX: ;循环交替
MOV A,30H
RL A
MOV 30H,A
MOV A,31H
RR A
MOV 31H,A
ANL A,30H
MOV P1,A
MOV DBUF+1,#4
MOV DBUF+0,#2
LJMP QQQ2
EXIT:
POP PSW
RETI
QS: MOV R7,#64H ;快
MOV DBUF+3,#0
MOV DBUF+2,#1
; 数码管 1 调用 高速/ 低速
QQQ1:
DISP:
MOV R0,#DBUF
MOV R1,#TEMP
MOV R2,#4
DP10:
MOV DPTR,#SEGTAB
MOV A, @R0
MOVC A,@A+DPTR
MOV @R1,A
INC R0
INC R1
DJNZ R2,DP10
MOV R0,#TEMP
MOV R1,#4
DP12:
MOV R2,#8
MOV A,@R0
DP13:
RLC A
MOV DIN,C
CLR CLK
SETB CLK
DJNZ R2,DP13
INC R0
DJNZ R1,DP12
SEGTAB:
DB 76H,40H,77H,6DH,38H
LJMP FX
; 数码管2 调用 左移/右移/循环交替
QQQ2:
DISP2:
MOV R0,#DBUF
MOV R1,#TEMP
MOV R2,#4
DP102:
MOV DPTR,#SEGTAB2
MOV A, @R0
MOVC A,@A+DPTR
MOV @R1,A
INC R0
INC R1
DJNZ R2,DP102
MOV R0,#TEMP
MOV R1,#4
DP122:
MOV R2,#8
MOV A,@R0
DP132:
RLC A
MOV DIN,C
CLR CLK
SETB CLK
DJNZ R2,DP132
INC R0
DJNZ R1,DP122
SEGTAB2:
DB 76H,40H,77H,6DH,38H
LJMP EXIT
;主程序 给初值
START:
MOV TMOD,#01H
MOV TH0,#0DAH
MOV TL0,#80H
MOV IE,#82H
SETB TR0
MOV 20H,#0FEH
MOV 21H,#7FH
MOV 30H,#0FEH
MOV 31H,#7FH
LOOP:
LJMP LOOP ;延时程序
END |