汇编实现八位和十六位流水灯
代码:
ORG 00H
START:MOV 30H,#0FFH
MOV 31H,#0FFH
MOV 32H,#0FFH
CLR C
LOOP1:
MOV A,30H
RRC A
MOV 30H,A
CJNE A,#07FH,RLCP0
CLR C
MOV A,31H
RLC A
MOV 31H,A
MOV P1,30H
MOV P0,31H
MOV P2,32H
CALL DELAY
JMP LOOP1
RLCP0:
SETB C
MOV A,31H
RLC A
MOV 31H,A
MOV P1,30H
MOV P0,31H
MOV P2,32H
CALL DELAY
MOV A,30H
CJNE A,#0FEH,LOOP1
MOV 31H,#0FFH
MOV 30H,#0FFH
CLR C
LOOP2:
MOV A,30H
RRC A
MOV 30H,A
CJNE A,#07FH,RLCP2
CLR C
MOV A,32H
RLC A
MOV 32H,A
MOV P1,30H
MOV P0,31H
MOV P2,32H
CALL DELAY
JMP LOOP2
RLCP2:
SETB C
MOV A,32H
RLC A
MOV 32H,A
MOV P1,30H
MOV P0,31H
MOV P2,32H
CALL DELAY
MOV A,30H
CJNE A,#0FEH,LOOP2
MOV 31H,#0FFH
MOV 30H,#0FFH
JMP START
DELAY:MOV R3,#50
D1: MOV R4,#20
D2: MOV R5,#248
DJNZ R5,$
DJNZ R4,D2
DJNZ R3,D1
RET
END
|