花样流水灯(汇编)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

花样流水灯程序(汇编)汇编起始命令统一为:ORG 0000H

LJMP MAIN

ORG 0100H

延时程序统一为:DELAY: MOV R7, #10 (延时500ms)

DL Y2: MOV R6, #200

DL Y1: MOV R5, #125

DJNZ R5, $

DJNZ R6, DL Y1

DJNZ R7, DL Y2

RET 注:不可少

1.普通流水灯

MAIN: MOV A, #0FEH

LOOP0: MOV R1,#10H

LOOP1: MOV P1,A

LCALL DELAY

RL A

DJNZ R1,LOOP1

LCALL DELAY 注:每循环一次延时长一些,以便观察

LCALL DELAY

SJMP LOOP0

2.L1亮到L8,L8灭到L1

MAIN: MOV A, #0FEH LOOP0:MOV R1, #15

LOOP1: MOV P1, A

LCALL DELAY

RL A

DEC R1

CJNE R1, #07H,LOOP1

RR A

LOOP2: RR A

MOV P1, A

LCALL DELAY

DJNZ R1, LOOP2

LCALL DELAY

LCALL DELAY

SJMP LOOP0 MAIN: MOV A, #0FEH LOOP0: MOV R1, #08

MOV R2, #08 LOOP1: MOV P1, A

LCALL DELAY

RL A

DEC R1

DJNZ R1, LOOP1

RR A

LOOP2: RR A

MOV P1, A

LCALL DELAY

DJNZ R2, LOOP2

LCALL DELAY

LCALL DELAY

SJMP LOOP0

3.L1到L8逐个亮灭

MAIN: MOV A, #0FEH

LOOP0: MOV R1, #0FEH

MOV R2, #15

LOOP1: MOV P1, A

LCALL DELAY

RL A

ANL A, R1

DEC R2

CJNE R2, #07H,LOOP1 注:以上是让灯从1亮到8

MOV R1, #80H

LOOP2: ORL A, R1

MOV P1, A

LCALL DELAY

RR A

DJNZ R2, LOOP2

RL A

LCALL DELAY

LCALL DELAY

SJMP LOOP0

4.13572468亮

MAIN: MOV A,#0FEH

LOOP0: MOV R1,#08H

LOOP1: MOV P1, A

LCALL DELAY

RL A

RL A

DEC R1

CJNE R1,#04H ,LOOP1

MOV A, #0FDH LOOP2: MOV P1, A

LCALL DELAY

RL A

RL A

DJNZ R1, LOOP2

RR A

SJMP LOOP0 5.逐个闪烁

MAIN: MOV A, #0FEH LOOP0: MOV R1,#10H LOOP1: MOV P1,A

LCALL DELAY

MOV P1, #0FFH

LCALL DELAY

RL A

DJNZ R1,LOOP1

LCALL DELAY

LCALL DELAY

SJMP LOOP0

6.流水灯四个四个地亮花样I

MAIN: MOV A, #0F0H LOOP0: MOV R1, #09H LOOP1: MOV P1, A

LCALL DELAY

RL A

花样II

MAIN: MOV A, #0F0H

LOOP0: MOV R1, #040H LOOP1: MOV P1, A

LCALL DELAY

SWAP A

DJNZ R1, LOOP1

LCALL DELAY

DEC R1

CJNE R1,#05H,LOOP1 LOOP2: MOV P1, A

LCALL DELAY

RR A

DJNZ R1,LOOP2

RL A LCALL DELAY LCALL DELAY SJMP LOOP0 LCALL DELAY SJMP LOOP0

7.全亮全灭

MAIN:

LOOP0: MOV R1, #04H LOOP1: MOV P1, #00H

LCALL DELAY

MOV P1, #0FFH

LCALL DELAY

DJNZ R1, LOOP1

LCALL DELAY

LCALL DELAY

SJMP LOOP0

8.两个两个地亮

MAIN: MOV A, #0FCH LOOP0: MOV R1, #08H LOOP1: MOV P1, A

LCALL DELAY

RL A

RL A

DEC R1

CJNE R1,#04H,LOOP1

RR A

RR A

LOOP2: MOV P1, A

LCALL DELAY

RR A

RR A

DJNZ R1, LOOP2

RL A

RL A

LCALL DELAY

LCALL DELAY

SJMP LOOP0 9.穿越

MAIN: MOV R2,#0FEH

MOV R3, #7FH LOOP0: MOV R1,#016 LOOP1: MOV A,R2

ANL A,R3

MOV P1, A

LCALL DELAY

MOV A,R2

RL A

MOV R2, A

MOV A,R3

RR A

MOV R3, A

DJNZ R1,LOOP1

相关文档
最新文档