单片机跑马灯程序 汇编语言编写,很简单 20
用八个LED发光二极管实现跑马灯即八个灯依次轮流发光每次只控制一个等,系统启动后,跑马灯向右流水,按下k1件则反向流水,再按则再反向老师要求用汇编程序写,由于刚学所以现在...
用八个LED发光二极管实现跑马灯即八个灯依次轮流发光每次只控制一个等,系统启动后,跑马灯向右流水,按下k1件则反向流水,再按则再反向 老师要求用汇编程序写,由于刚学所以现在还不会,七点半之前要用,求大神给力
展开
2个回答
展开全部
程序1:
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV SP,#5FH
LOOP:
MOV A,P2
MOV B,A
MOV P0,A
MOV P1,#0FFH
LOOP1:
LCALL DELAY
MOV C,P1.7
MOV A,P0
RLC A
MOV P0,A
MOV A,P1
RLC A
MOV P1,A
MOV A,P2
CJNE A,B,LOOP
SJMP LOOP1
DELAY:
MOV R2,#60
DELAY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DELAY1
RET
END
程序2:
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV SP,#5FH
JNB P2.0,LOOP1 ;
JNB P2.1,LOOP2 ;
SJMP MAIN
LOOP1:
MOV P0,#0FEH
MOV P1,#0FFH
LOOP11:
MOV C,P1.7
MOV A,P0
RLC A
MOV P0,A
MOV A,P1
RLC A
MOV P1,A
JNB P2.1,LOOP2
SJMP LOOP11
LOOP2:
MOV P0,#0FCH
MOV P1,#0FFH
LOOP21:
MOV C,P1.7
MOV A,P0
RLC A
MOV P0,A
MOV A,P1
RLC A
MOV P1,A
JNB P2.0,LOOP1
SJMP LOOP21
DELAY:
MOV R2,#60
DELAY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DELAY1
RET
END
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询