单片机汇编语言写八个灯从左至右点亮,再从右到左点亮程序。谢谢
4个回答
展开全部
ORG 0000H
LJMP MAIN
ORG 000BH
T0MS0 EQU NOT 50000 ; 50 mS 12.000 MHz
T0ZD0: MOV TL0, #LOW T0MS0 ; TO 100MS 中断 计时 0
MOV TH0, #HIGH T0MS0
DJNZ R5, T0ZD8
MOV R5, #20
SETB 30H
T0ZD8: RETI
MAIN: MOV TL0, #LOW T0MS0 ; TO 100MS 中断 计时 0
MOV TH0, #HIGH T0MS0
MOV IE, #82H
SETB TR0
MOV R5, #20
MAIN1: MOV A, #0FEH
MOV R2, #8
MAIN2: MOV P1, A
JNB 30H, $
CLR 30H
RL A
DJNZ R2, MAIN2
MOV A, #7FH
MOV R2, #8
MAIN3: MOV P1, A
JNB 30H, $
CLR 30H
RR A
DJNZ R2, MAIN3
JMP MAIN1
END
LJMP MAIN
ORG 000BH
T0MS0 EQU NOT 50000 ; 50 mS 12.000 MHz
T0ZD0: MOV TL0, #LOW T0MS0 ; TO 100MS 中断 计时 0
MOV TH0, #HIGH T0MS0
DJNZ R5, T0ZD8
MOV R5, #20
SETB 30H
T0ZD8: RETI
MAIN: MOV TL0, #LOW T0MS0 ; TO 100MS 中断 计时 0
MOV TH0, #HIGH T0MS0
MOV IE, #82H
SETB TR0
MOV R5, #20
MAIN1: MOV A, #0FEH
MOV R2, #8
MAIN2: MOV P1, A
JNB 30H, $
CLR 30H
RL A
DJNZ R2, MAIN2
MOV A, #7FH
MOV R2, #8
MAIN3: MOV P1, A
JNB 30H, $
CLR 30H
RR A
DJNZ R2, MAIN3
JMP MAIN1
END
展开全部
以下程序循环执行你表述的状态:
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV A,#0FEH
MOV R2,#8
LOOP1:
MOV P0,A
LCALL DELAY
RL A
DJNZ R2,LOOP1
MOV R2,#8
LOOP2:
MOV P0,A
LCALL DELAY
RR A
DJNZ R2,LOOP2
SJMP LOOP1
DELAY:
MOV R3,#100
DELAY1:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DELAY1
RET
END
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV A,#0FEH
MOV R2,#8
LOOP1:
MOV P0,A
LCALL DELAY
RL A
DJNZ R2,LOOP1
MOV R2,#8
LOOP2:
MOV P0,A
LCALL DELAY
RR A
DJNZ R2,LOOP2
SJMP LOOP1
DELAY:
MOV R3,#100
DELAY1:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DELAY1
RET
END
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ORG 0000H
MOV A,#0FEH
MOV B,#08
L1: MOV P0,A
RL A
ACALL YS ;延时子程序
DJNZ B,L1
MOV B,#08H
L2: MOV P0,A
RR A
DJNZ B,L2
SJMP $
YS: MOV R6,#00H
YS1:MOV R7,#00H
YS2:NOP
DJNZ R7,YS2
DJNZ R6,YS1
RET
END
MOV A,#0FEH
MOV B,#08
L1: MOV P0,A
RL A
ACALL YS ;延时子程序
DJNZ B,L1
MOV B,#08H
L2: MOV P0,A
RR A
DJNZ B,L2
SJMP $
YS: MOV R6,#00H
YS1:MOV R7,#00H
YS2:NOP
DJNZ R7,YS2
DJNZ R6,YS1
RET
END
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询