51单片机流水灯查表法实现多种流水灯运行方式汇编语言程序
时间: 2023-06-11 21:09:07 浏览: 161
51单片机经典流水灯汇编程序.doc
以下是51单片机流水灯查表法实现多种流水灯运行方式汇编语言程序。
```assembly
;----------------------------------
; 功能:多种流水灯运行方式
; 作者:CSDN开发的ChitGPT
;----------------------------------
ORG 0000H
;-------------------------
; 变量定义
;-------------------------
ORG 0030H
DB 0FFH, 0FEH, 0FDH, 0FBH, 0F7H, 0EFH, 0DFH, 0BFH, 07FH, 0FEH, 0FDH, 0FBH, 0F7H, 0EFH, 0DFH, 0BFH, 07FH, 0FEH, 0FDH, 0FBH, 0F7H, 0EFH, 0DFH, 0BFH, 07FH, 0FEH, 0FDH, 0FBH, 0F7H, 0EFH, 0DFH, 0BFH, 07FH
DB 01H, 02H, 04H, 08H, 10H, 20H, 40H, 80H
DB 80H, 40H, 20H, 10H, 08H, 04H, 02H, 01H
DB 01H, 03H, 07H, 0FH, 1FH, 3FH, 7FH, 0FFH
DB 0FFH, 7FH, 3FH, 1FH, 0FH, 07H, 03H, 01H
DB 01H, 05H, 15H, 55H, 15H, 05H, 01H
DB 81H, 41H, 21H, 11H, 21H, 41H, 81H
DB 01H, 04H, 10H, 40H, 10H, 04H, 01H
DB 81H, 24H, 81H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
;-------------------------
; 程序代码
;-------------------------
ORG 0000H
MOV P0, #0FFH ;P0口全部输出低电平
MOV DPTR, #0030H ;将表格数据存储区的首地址送入DPTR
MAIN:
MOV R0, #08H ;R0计数器初始化
LOOP:
MOV A, @DPTR ;将表格中的数据读出
INC DPTR ;指向下一个数据
MOV P0, A ;将数据送入P0口
ACALL DELAY ;延时一段时间
DJNZ R0, LOOP ;计数器减一
SJMP MAIN ;一轮结束,回到循环开始
DELAY:
MOV R1, #255 ;R1计数器初始化
MOV R2, #255 ;R2计数器初始化
DJNZ R1, $ ;第一层循环
DJNZ R2, $-1 ;第二层循环
RET
END
```
其中,表格数据存储区的首地址为0030H,包含了多种流水灯运行方式对应的数据。程序通过循环读取表格中的数据,并将数据送入P0口,实现多种流水灯运行方式。DELAY子程序用于延时一段时间,以控制流水灯的速度。
阅读全文