用汇编语言给51单片机编程四种流水灯

2024-12-26 17:22:27
推荐回答(1个)
回答1:

ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV 30H,#0FEH
MOV 31H,01H
MOV 32H,#55H
LOOP:
MOV A,P1
ANL A,#03H
JNZ LOOP1
MOV A,30H
MOV P0,A
RL A
MOV 30H,A
LCALL DELAY
SJMP LOOP
LOOP1:
DEC A
JNZ LOOP2
MOV A,30H
MOV P0,A
RR A
MOV 30H,A
LCALL DELAY
SJMP LOOP
LOOP2:
DEC A
JNZ LOOP3
MOV A,31H
MOV P0,A
CJNE A,#0FFH,LOOP21
MOV A,#01H
SJMP LOOP22
LOOP21:
SETB C
RLC A
LOOP22:
MOV 31H,A
LCALL DELAY
SJMP LOOP
LOOP3:
MOV A,32H
MOV P0,A
CPL A
MOV 32H,A
LCALL DELAY
LJMP LOOP
END