试验要求:
P1.0、P1.1分别接两个发光二极管,INT0脚接一按键做开关,按一次开关,则启动,两个发光管一亮一灭,亮灭时间均为1秒;再按一次开关,则关闭,即两个发光管都灭。
ORG 0000H
SJMP MAIN
ORG 0003H
LJMP INT0INT
ORG 000BH
AJMP TIME0
ORG 0030H
MAIN: SETB 20H.0
CLR P1.0
CLR P1.1
MOV R0,#00H
SETB EX0
SETB IT0
SETB EA
SJMP $
INT0INT:CPL 20H.0
JB 20H.0,L1
CLR TR0
CLR ET0
CLR P1.0
CLR P1.1
SJMP L2
L1: SETB P1.0
CLR P1.1
MOV TMOD,#00000001B
MOV TH0,#0B0H
MOV TL0,#3CH
SETB TR0
MOV IP,#08H
SETB ET0
L2: NOP
RETI
TIME0: MOV TH0,#0B0H
MOV TL0,#3CH
INC R0
CJNE R0,#0AH,L3
CPL P1.0
CPL P1.1
MOV R0,#00H
L3:
RETI