用汇编语言编写跑马灯程序
单片机为AT89c51型,八个跑马灯接P1口,开始是1357灯亮,延迟400ms,接着是2468灯亮,延时…一直循环下去,程序要有简略说明…不要用c语言编写发我邮箱,62...
单片机为AT89c51型,八个跑马灯接P1口,开始是1357灯亮,延迟400ms,接着是2468灯亮,延时…一直循环下去,程序要有简略说明…不要用c语言编写
发我邮箱,624431977@qq.com 展开
发我邮箱,624431977@qq.com 展开
4个回答
展开全部
跑马灯程序用汇编是很好实现的,只要用好循环移位指令就可以,以下是程序。
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV A,#0FEH
LOOP:
MOV P1,A ;将控制字送端口
RL A ;控制字循环左移
LCALL DELAY ;延时
SJMP LOOP
DELAY: ;延时大概1秒
MOV R2,#10
DLY1:
MOV R3,#200
DLY2:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DLY2
DJNZ R2,DLY1
RET
END
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV A,#0FEH
LOOP:
MOV P1,A ;将控制字送端口
RL A ;控制字循环左移
LCALL DELAY ;延时
SJMP LOOP
DELAY: ;延时大概1秒
MOV R2,#10
DLY1:
MOV R3,#200
DLY2:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DLY2
DJNZ R2,DLY1
RET
END
展开全部
CSEG AT 0000H
LJMP START
CSEG AT 401BH
LJMP INT
CSEG AT 4100H
START: MOV A,#01H
MOV R1,#03H
MOV R0,#5H
MOV TMOD,#10H
MOV TL1,#57H
MOV TH1,#9EH
ORL IE,#88H
SETB TR1
LOOP1: CJNE R0,#00,DISP
MOV R0,#5H
INC R1
CJNE R1,#27H,LOOP2
MOV R1,#03H
LOOP2: MOV A,R1
MOVC A,@A+PC
JMP DISP
DB 01H,03H,07H,0FH,1FH,3FH,7FH,0FFH,0FEH,0FCH
DB 0F8H,0F0H,0E0H,0C0H,80H,00H,0FFH,00H,0FEH
DB 0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH,0BFH,0DFH
DB 0EFH,0F7H,0FBH,0FDH,0FEH,00H,0FFH,00H
DISP: MOV P1,A
JMP LOOP1
INT: CLR TR1
DEC R0
MOV TL1,#57H
MOV TH1,#9EH
SETB TR1
RETI
END
LJMP START
CSEG AT 401BH
LJMP INT
CSEG AT 4100H
START: MOV A,#01H
MOV R1,#03H
MOV R0,#5H
MOV TMOD,#10H
MOV TL1,#57H
MOV TH1,#9EH
ORL IE,#88H
SETB TR1
LOOP1: CJNE R0,#00,DISP
MOV R0,#5H
INC R1
CJNE R1,#27H,LOOP2
MOV R1,#03H
LOOP2: MOV A,R1
MOVC A,@A+PC
JMP DISP
DB 01H,03H,07H,0FH,1FH,3FH,7FH,0FFH,0FEH,0FCH
DB 0F8H,0F0H,0E0H,0C0H,80H,00H,0FFH,00H,0FEH
DB 0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH,0BFH,0DFH
DB 0EFH,0F7H,0FBH,0FDH,0FEH,00H,0FFH,00H
DISP: MOV P1,A
JMP LOOP1
INT: CLR TR1
DEC R0
MOV TL1,#57H
MOV TH1,#9EH
SETB TR1
RETI
END
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
START:MOV A,#0AAH;初次1357灯亮
LOOP :MOV P1,A
LCALL DELY
LCALL DELY ;调200mS延时
RL A
SJMP LOOP
DELY:MOV R7,#200
DELY1:MOV R6,#200
DELY2:NOP
NOP
NOP
DJNZ R6,DELY2
DJNZ R7,DELY1
RET
LOOP :MOV P1,A
LCALL DELY
LCALL DELY ;调200mS延时
RL A
SJMP LOOP
DELY:MOV R7,#200
DELY1:MOV R6,#200
DELY2:NOP
NOP
NOP
DJNZ R6,DELY2
DJNZ R7,DELY1
RET
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ORG 0600H
MOV A,#55H
LOOP: MOV P1,A
LCALL DEL
RL A
SJMP LOOP
DEL: MOV R7,#250
DEL1: MOV R6,#198
DJNZ R6,$
DJNZ R7,DEL1
RET
END
MOV A,#55H
LOOP: MOV P1,A
LCALL DEL
RL A
SJMP LOOP
DEL: MOV R7,#250
DEL1: MOV R6,#198
DJNZ R6,$
DJNZ R7,DEL1
RET
END
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询