我是用最基本的汇编来编的,用89C2051做的,用中断来做的,呜呜,搞了很久就是不知道原因在哪里?大夹帮帮忙吧?
CP17 BIT P1.2
CP16 BIT P1.0
CP15 BIT P1.1
CP32 BIT P3.2 ;INTO
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTT0
ORG 0100H
MAIN: MOV SP , #60H
SETB IT0
MOV IP , #00000001B
SETB EA
SETB EX0
MOV P1 , #00H
SETB CP32
CLR A
KAIJI: CJNE A , #1CH , KJWAIT
AJMP KJ
KJWAIT:AJMP KAIJI
KJ: CLR CP17
CLR CP16
SETB CP15
CLR A
YUNXIN:CJNE A , #00H , TT0
AJMP YUNXIN
TT0: CJNE A , #19H , TT1
ACALL KEYW
AJMP YUNXIN
TT1: CJNE A , #01H , TT2
ACALL KEYR
AJMP YUNXIN
TT2: CJNE A , #02H , TT3
ACALL KEYG
AJMP YUNXIN
TT3: CJNE A , #03H , TT4
ACALL KEYB
AJMP YUNXIN
TT4: CJNE A , #15H , TT5
ACALL KEYOFF
TT5: AJMP YUNXIN
KEYW: SETB CP17
SETB CP16
SETB CP15
CLR A
RET
KEYR: SETB CP17
CLR CP16
CLR CP15
CLR A
RET
KEYG: CLR CP17
SETB CP16
CLR CP15
CLR A
RET
KEYB: CLR CP17
CLR CP16
SETB CP15
CLR A
RET
KEYOFF:CLR CP17
CLR CP16
CLR CP15
CLR A
RET
ORG 0200H
INTT0: PUSH DPH
PUSH DPL
CLR EA
MOV R2 , #32
MOV R6 , #10
JNB P3.2 , $
BYT1: JB P3.2 , $
JNB CP32 , $
MOV R6 , #3
S1: MOV R3 , #150
DJNZ R3 , $
DJNZ R6 , S1
MOV C , CP32
MOV R3 , #4
MOV R0 , #1DH
BYT2: MOV A , @R0
RRC A
MOV @R0 , A
DEC R0
DJNZ R3 , BYT2
DJNZ R2 , BYT1
MOV A , 1AH
XRL A , #40H
JNZ EXIT
MOV A , 1BH
XRL A , #0BFH
JNZ EXIT
MOV R2 , #6
MOV DPTR , #TABLE
LOOKUP:MOV A , R2
MOVC A , @A+DPTR
XRL A , 1CH
JZ EXIT1
DJNZ R2 , LOOKUP
AJMP EXIT
EXIT1: MOV A , 1CH
SJMP EDYK
EXIT: CLR A
EDYK: SETB EA
POP DPL
POP DPH
RETI
TABLE: DB 00H , 01H , 02H , 03H , 1CH , 15H , 19H
END