COMDAT EQU 30H
FLAG BIT 00H
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP EX0INT
ORG 0023H
LJMP SERINT
ORG 0030H
EX0INT:
CPL F0
JNB P3.2, $
RETI
SERINT:
PUSH ACC
JNB RI,SERR
CLR RI
MOV A,SBUF
MOV COMDAT,A
SETB FLAG
SERR:
POP ACC
RETI
MAIN:
MOV TMOD, #00H
MOV TH1, #0F0H
MOV TL1, #0CH
MOV IE, #81H ;开外部中断
SETB IT0
SETB TR1
CLR FLAG
LOOP:
JNB FLAG,LOOPC
CLR FLAG
MOV A,COMDAT
.........处理接收到的命令。
LOOPC:
JBC TF1, LOOP1
JB F0, $
AJMP LOOP
LOOP1:
MOV TH1, #0F0H
MOV TL1, #0CH
CLR TF1
CPL P1.7
AJMP LOOP
END