我的程式如下:
ORG 00H
SETB EA
MOV TMOD, #00100000B ;8 bits auto-reload mode
MOV TH1, #0F4H
MOV TL1, #0F4H ;2400 baud rate
MOV SCON,#01000010B ;8 Bits,set by timer 1, with TI ready
ANL PCON,#01111111B;Close SMOD
LJMP BEGIN
BEGIN: MOV SP,#60H
CALL INIT_RS232
CALL SCAN_KEY
MOVC A,@A+DPTR
MOV SBUF,A ;Send out the data
?? ;不知道接下來怎么寫=o=,不知道用不用call delay
JMP $
SCAN_KEY: PUSH R0
MOV R0,#11111110B
LOOP: MOV P1, R0
MOV A, P1
ORL A,#00001111B
CPL A
JNZ RETURN_VALUE
MOV A, R0
RL A
MOV R0, A
ANL A, #00010000B
MOV DPTR, A
POP R0
JNZ LOOP
RETURN_VALUE:MOV A, P1
INIT_RS232:
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#0F4H
SETB TR1
SETB TI
RET