ORG 00H
JMP START
ORG 30H
START:
MOV P0,#00000000B
MOV P3,#00000000B
MOV A,#00000011B
;=====
;
;=====
BEGIN:
MOV P1,#11111100B
MOV P2,#00001111B
CALL DELAY
MOV P1,#00000000B
MOV P2,#00000000B
CALL DELAY
DJNZ ACC,BEGIN
CALL CASE
BEGIN2:
MOV P0,#11111111B
MOV P1,#00000011B
MOV P2,#11110000B
MOV P3,#11111111B
CALL DELAY
MOV P0,#00000000B
MOV P2,#00000000B
MOV P1,#00000000B
MOV P3,#00000000B
CALL DELAY
DJNZ ACC,BEGIN2
BEGIN3:
MOV P0,#00000000B
MOV P2,#00000000B
MOV P1,#00000000B
MOV P3,#00000000B
CALL CASEDELAY
MOV R2,#00000011B
;=====
;以下為跑馬燈由內側往外跑
;=====
BEGIN4:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#11000000B
MOV R0,#01000000B
MOV R1,#10000000B
MOV A,R0
RR A
MOV R0,A
MOV A,R1
RL A
MOV R1,A
CALL DELAY
BEGIN5:
MOV P1,R0
MOV P2,R1
MOV A,R0
RR A
MOV R0,A
MOV P1,R0
MOV A,R1
RL A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P1.0,BEGIN6
JMP BEGIN5
BEGIN6:
MOV P0,R0
MOV P2,R1
MOV A,R0
RR A
MOV R0,A
MOV P0,R0
MOV A,R1
RL A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P2.7 ,BEGIN7
JMP BEGIN6
BEGIN7:
MOV P0,R0
MOV P3,R1
MOV A,R0
RR A
MOV R0,A
MOV P0,R0
MOV A,R1
RL A
MOV R1,A
MOV P3,R1
CALL DELAY
JBC P0.0, BEGINA
JMP BEGIN7
BEGINA:
DEC R2
CJNE R2,#00H,BEGIN4
MOV P0,#00000001B
MOV P3,#10000000B
MOV R0,#00000001B
MOV R1,#10000000B
MOV R2,#00000011B
JMP BEGIN8
;=====
;以下為跑馬燈由外側往內側跑
;=====
BEGIN8:
MOV A,R0
RL A
MOV R0,A
MOV P0,R0
MOV A,R1
RR A
MOV R1,A
MOV P3,R1
CALL DELAY
JBC P0.7,BEGIN9
JMP BEGIN8
BEGIN9:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#00000000B
MOV P2,#00000000B
MOV A,R0
RL A
MOV R0,A
MOV P1,R0
MOV A,R1
RR A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P1.7,BEGINB
JMP BEGIN9
BEGINB:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#00000000B
MOV P2,#00000000B
DEC R2
CJNE R2,#00H,BEGIN8
CALL CASEDELAY ;呼叫延遲2秒
CALL CASE ;呼叫A的值3
JMP BEGIN
;=====
;設A的值為3
;=====
CASE:
MOV A,#0000011B
;======
;延遲2秒
;======
CASEDELAY:
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
;=====
;延遲0.5秒
;=====
DELAY:
MOV R7,#01
L3:
MOV R6,#200
L2:
MOV R5,#248
NOP
L1:
DJNZ R5,L1
DJNZ R6,L2
DJNZ R7,L3
RET
END
JMP START
ORG 30H
START:
MOV P0,#00000000B
MOV P3,#00000000B
MOV A,#00000011B
;=====
;
;=====
BEGIN:
MOV P1,#11111100B
MOV P2,#00001111B
CALL DELAY
MOV P1,#00000000B
MOV P2,#00000000B
CALL DELAY
DJNZ ACC,BEGIN
CALL CASE
BEGIN2:
MOV P0,#11111111B
MOV P1,#00000011B
MOV P2,#11110000B
MOV P3,#11111111B
CALL DELAY
MOV P0,#00000000B
MOV P2,#00000000B
MOV P1,#00000000B
MOV P3,#00000000B
CALL DELAY
DJNZ ACC,BEGIN2
BEGIN3:
MOV P0,#00000000B
MOV P2,#00000000B
MOV P1,#00000000B
MOV P3,#00000000B
CALL CASEDELAY
MOV R2,#00000011B
;=====
;以下為跑馬燈由內側往外跑
;=====
BEGIN4:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#11000000B
MOV R0,#01000000B
MOV R1,#10000000B
MOV A,R0
RR A
MOV R0,A
MOV A,R1
RL A
MOV R1,A
CALL DELAY
BEGIN5:
MOV P1,R0
MOV P2,R1
MOV A,R0
RR A
MOV R0,A
MOV P1,R0
MOV A,R1
RL A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P1.0,BEGIN6
JMP BEGIN5
BEGIN6:
MOV P0,R0
MOV P2,R1
MOV A,R0
RR A
MOV R0,A
MOV P0,R0
MOV A,R1
RL A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P2.7 ,BEGIN7
JMP BEGIN6
BEGIN7:
MOV P0,R0
MOV P3,R1
MOV A,R0
RR A
MOV R0,A
MOV P0,R0
MOV A,R1
RL A
MOV R1,A
MOV P3,R1
CALL DELAY
JBC P0.0, BEGINA
JMP BEGIN7
BEGINA:
DEC R2
CJNE R2,#00H,BEGIN4
MOV P0,#00000001B
MOV P3,#10000000B
MOV R0,#00000001B
MOV R1,#10000000B
MOV R2,#00000011B
JMP BEGIN8
;=====
;以下為跑馬燈由外側往內側跑
;=====
BEGIN8:
MOV A,R0
RL A
MOV R0,A
MOV P0,R0
MOV A,R1
RR A
MOV R1,A
MOV P3,R1
CALL DELAY
JBC P0.7,BEGIN9
JMP BEGIN8
BEGIN9:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#00000000B
MOV P2,#00000000B
MOV A,R0
RL A
MOV R0,A
MOV P1,R0
MOV A,R1
RR A
MOV R1,A
MOV P2,R1
CALL DELAY
JBC P1.7,BEGINB
JMP BEGIN9
BEGINB:
MOV P0,#00000000B
MOV P3,#00000000B
MOV P1,#00000000B
MOV P2,#00000000B
DEC R2
CJNE R2,#00H,BEGIN8
CALL CASEDELAY ;呼叫延遲2秒
CALL CASE ;呼叫A的值3
JMP BEGIN
;=====
;設A的值為3
;=====
CASE:
MOV A,#0000011B
;======
;延遲2秒
;======
CASEDELAY:
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
;=====
;延遲0.5秒
;=====
DELAY:
MOV R7,#01
L3:
MOV R6,#200
L2:
MOV R5,#248
NOP
L1:
DJNZ R5,L1
DJNZ R6,L2
DJNZ R7,L3
RET
END
全站熱搜
留言列表