求16位流水灯收缩点亮汇编程序

求16位流水灯收缩点亮汇编程序,第1张

如下即可:

ORG 0000H

MOV 30H, #255

MOV 31H, #255

M_LOOP:

MOV R2, #8

DISP1:

MOV P1, 30H

MOV P2, 31H

CALL SHIFT1

CALL DL

DJNZ R2, DISP1

MOV R2, #8

DISP2:

MOV P1, 30H

MOV P2, 31H

CALL SHIFT2

CALL DL

DJNZ R2, DISP2

SJMP M_LOOP

-----------------------

SHIFT1:

CLR C

MOV A, 30H

RLC A

MOV 30H, A

CLR C

MOV A, 31H

RRC A

MOV 31H, A

RET

-----------------------

SHIFT2:

SETB C

MOV A, 31H

RLC A

MOV 31H, A

SETB C

MOV A, 30H

RRC A

MOV 30H, A

RET

-----------------------

DL:

DJNZ R7, $

DJNZ R7, $

DJNZ R6, $ - 4

RET

-----------------------

END

#include<reg52.h>

#include <intrins.h>

void delayms(unsigned char ms) // 延时子程序

{

unsigned char i

while(ms--)

{

for(i = 0i <120i++)

}

}

main()

{

unsigned char LED

LED = 0xff

P0 = LED

while(1)

{

delayms(1000)

LED = LED<<1 //循环右移1位,点亮下一个LED

if(LED==0x00)

{

LED=0xff

}

P0 = LED

}

}


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存