Day01
作者:互联网
开关控制单灯亮灭
ORG 0000H
LJMP START;指定下一个的起始地址
START:
CLR P1.0
LCALL DELAY
SETB P1.0
LCALL DELAY
AJMP START
DELAY: MOV R7,#250
D1: MOV R6,#250
D2: DJNZ R6,D2
DJNZ R7,D1
RET
END
ORG 0000H
CLR P1.0
AJMP START
START:
SETB P0.0
JB P0.0,LIG;为0跳转
SETB P1.0
SJMP START
LIG:
CLR P1.0
SJMP START
END
开关控制多灯亮灭
ORG 0000H
CLR P1.0
CLR P1.1
CLR P1.2
AJMP START
START:SETB P0.0
SETB P0.1
SETB P0.2
JB P0.0,LIG0
SETB P1.0
SJMP NEXT1
LIG0:CLR P1.0
NEXT1:JB P0.1,LIG1
SETB P1.1
SJMP NEXT2
LIG1:CLR P1.1
NEXT2:JB P0.2,LIG2
SETB P1.2
SJMP NEXT3
LIG2:CLR P1.2
NEXT3:JB P0.3,LIG3
SETB P1.3
SJMP NEXT4
LIG3:CLR P1.3
NEXT4:JB P0.4,LIG4
SETB P1.4
AJMP START
LIG4:CLR P1.4
SJMP START
END
延时程序
MOV Rn,#Data ;1个周期
DJNZ Rn,Rel ;2
RET ;2
NOP ;1
ACALL Addr11 ;2
LCALL Addr16 ;2
ADD A,Ri ;1
INC DPTR ;2
DEL2:MOV R0,#X ;1周期
DEL1:DJNZ R0,DEL1 ;2周期,不为0转移
RET ;2周期
;(2X+3)T
;双重循环
DEL3:MOV R1,#Y;1
DEL2:MOV R0,#X;1
DEL1:DJNZ R0,DEL1;2
DJNZ R1,DEL2;2
RET;2
;设计一个延时100微秒的程序,12MHZ
MOV R0,#049 ;1
Loop:DJNZ R0,loop ;2
RET ;2
;--------------------------
MOV R0,#048
NOP
LOOP:DJNZ R0,LOOP
RET
标签:R0,SETB,Day01,MOV,START,DJNZ,CLR 来源: https://www.cnblogs.com/Unclesundada/p/16265289.html