用汇编语言:单片机P1口接8个LED灯,按P3.1键时,灯由下往上亮,按P3.2键时候,灯从上往下亮

(可以逐个点亮也可以顺序点亮)
2024-12-25 17:43:30
推荐回答(1个)
回答1:

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