5.程序框图
图4.9.2
6.汇编源程序
ID EQU 30H
SP1 BIT P3.7
L1 BIT P1.0
L2 BIT P1.1
L3 BIT P1.2
L4 BIT P1.3
ORG 0
MOV ID,#00H
START: JB K1,REL
LCALL DELAY10MS
JB K1,REL
INC ID
MOV A,ID
CJNE A,#04,REL
MOV ID,#00H
REL: JNB K1,$
MOV A,ID
CJNE A,#00H,IS0
CPL L1
LCALL DELAY
SJMP START
IS0: CJNE A,#01H,IS1
CPL L2
LCALL DELAY
SJMP START
IS1: CJNE A,#02H,IS2
CPL L3
LCALL DELAY
SJMP START
IS2: CJNE A,#03H,IS3
CPL L4
LCALL DELAY
SJMP START
IS3: LJMP START
DELAY10MS: MOV R6,#20
LOOP1: MOV R7,#248
DJNZ R7,$
DJNZ R6,LOOP1
RET
DELAY: MOV R5,#20
LOOP2: LCALL DELAY10MS
DJNZ R5,LOOP2
RET
END
|