谁能帮我用汇编语言编写一个程序,急用!

2025-01-03 14:50:28
推荐回答(1个)
回答(1):

SCANCODE EQU 30H
DISPDATA EQU 31H
KEY1 EQU P1.0
KEY2 EQU P1.1
KEY3 EQU P1.2
KEY4 EQU P1.3
ORG 0000H
LJMP MAIN
ORG 001BH
LJMP T1ISR ;扫描显示
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#11H
MOV TH1,#0ECH
MOV TL1,#078H
SETB TR1
SETB ET1
SETB EA
MOV DISPDATA,#8
LOOP:
JB KEY1,LOOP1
JNB KEY1,$
MOV DISPDATA,#0
SJMP LOOP
LOOP1:
JB KEY2,LOOP2
JNB KEY2,$
MOV DISPDATA,#1
SJMP LOOP
LOOP2:
JB KEY3,LOOP3
JNB KEY3,$
MOV DISPDATA,#2
SJMP LOOP
LOOP3:
JB KEY4,LOOP4
JNB KEY4,$
MOV DISPDATA,#3
SJMP LOOP
LOOP4:
MOV DISPDATA,#8
LJMP LOOP
T1ISR:
PUSH ACC
CLR TR1
MOV TH1,#0ECH
MOV TL1,#78H
SETB TR1
MOV DPTR,#LEDTAB
T100:
MOV A,SCANLED
JNZ T101
MOV P2,#01H
SJMP T1DIS
T101:
DEC A
JNZ T102
MOV P2,#02H
SJMP T1DIS
T102:
DEC A
JNZ T103
MOV P2,#04H
SJMP T1DIS
T103:
DEC A
JNZ T1DIS
MOV P2,#08H
T1DIS:
MOV A,DISPDATA
MOVC A,@A+DPTR
CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
CJNE A,#4,T1END
MOV SCANLED,#0
T1END:
POP ACC
RETI
;--------------------
LEDTAB: DB 0FCH ;"0" 00H
DB 60H ;"1" 01H
DB 0DAH ;"2" 02H
DB 0F2H ;"3" 03H
DB 66H ;"4" 04H
DB 0B6H ;"5" 05H
DB 0BEH ;"6" 06H
DB 0E0H ;"7" 07H
DB 0FEH ;"8" 08H
DB 0F6H ;"9" 09H
DB 0EEH ;"A" 0AH
DB 3EH ;"B" 0BH
DB 9CH ;"C" 0CH
DB 7AH ;"D" 0DH
DB 9EH ;"E" 0EH
DB 8EH ;"F" 0FH
DB 00H ;" " 10H
;--------------------
END