用汇编语言编写一个按钮控制8个流水灯的亮灭

用汇编语言编写一个按钮控制8个流水灯的亮灭,第1张

51汇编程序如下:

KEY EQU P3.2

LED EQU P1

ORG 0000H

LJMP MAIN

ORG 0030H

MAIN:

CLR 00H

MOV A,#0FEH

LOOP:

JB P3.2,LOOP1

JNB P3.2,$

CPL 00H

LOOP1:

JB 00H,LOOP2

MOV LED,#0FFH

SJMP LOOP

LOOP2:

MOV P1,A

RL A

LCALL DELAY

SJMP LOOP

DELAY:

MOV R2,#200

DLY1:

MOV R3,#250

DJNZ R3,$

DJNZ R2,DLY1

RET

END

KEY BIT P1.0

LED EQU 30H

ORG 0000H

LJMP MAIN

ORG 0030H

MAIN:

MOV LED,#0FEH

MOV R2,#8

LOOP:

MOV P0,LED

MOV A,LED

RL A

MOV LED,A

JNB KEY,KEYC

DJNZ R2,LOOP

MOV R2,#8

LOOP1:

MOV P0,LED

MOV A,LED

RR A

MOV LED,A

JNB KEY,KEYC

DJNZ R2,LOOP1

SJMP LOOP

KEYC:

MOV P0,#00H

JNB KEY,KEYC

LJMP LOOP

END


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11086096.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存