谁能帮我看看这个程序有没有错啊
小弟前两天焊了一个板子,stc89c51的芯片,想做一个电子密码锁,但是最后程序出来后只能显示输入密码等,等到按键按下输入密码却总是没有效果出来啊。就是不能输入密码和修改密码。怎么办啊,求高手给看看哎程序代码:
RS BIT P2.2 RW BIT P2.1 E BIT P2.0 ORG 0000H AJMP START ORG 0050H START: MOV P0,#01H ACALL ENABLE MOV P0,#38H ACALL ENABLE MOV P0,#0FH ACALL ENABLE MOV P0,#06H MOV 50H,#1 MOV 51H,#2 MOV 52H,#0 MOV 53H,#4 MOV 54H,#5 MAIN: LCALL ENABLE LCALL KSXSHI AA: LCALL KEY CJNE A,#10,llo LP: ACALL ANAHX AJMP MAIN llo:CJNE A,#11,AA ACALL ANBHX ENABLE:CLR RS CLR RW CLR E LCALL DELAY SETB E RET ;。。。。。。。。。。。。。键盘编码。。。。。。。。。。。。。。。。。。 KEY: MOV P1,#0F0H KEY0:MOV A,P1 CPL A ANL A,#0F0H MOV R1,A JZ KEY KEY1:MOV P1,#0FH MOV A,P1 CPL A ANL A,#0FH MOV R2,A JZ KEY TT:JBC F0,WAIT SETB F0 LCALL DELAY SJMP TT GRET:RET ;........................确定按键值。。。。。。。。。。。。。。 WAIT:MOV A,P1 CPL A ANL A,#0FH JNZ WAIT KEY2:MOV A,R1 MOV R1,#03H MOV R3,#03H CLR C KEY3:RLC A JC KEY4 DEC R1 DJNZ R3,KEY3 KEY4:MOV A,R2 MOV R2,#00H MOV R3,#03H CLR C KEY5:RRC A JC KEY6 INC R2 DJNZ R3,KEY5 KEY6: MOV A,R2 CLR C RLC A RLC A ADD A,R1 RET ;.....................。。显示效果................................ KSXSHI: MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE3 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE2 LCALL WRITE1 RET ;*******************************按A后的操作部分****************** ANAHX:MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE4 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE5 LCALL WRITE1 LCALL XG_PASS RET ;********************************按B后的操作部分 *************** ANBHX:MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE6 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE5 LCALL WRITE1 LCALL IP_PASS RET ;******************************输入5位密码值********************** IP_PASS:MOV B,#5 MOV R0,#40H T:CLR P2.3 ACALL KEY SETB P2.3 MOV @R0,A INC R0 DJNZ B,T ACALL KEY CJNE A,#12H,PT MOV A,40H CJNE A,50H,KK MOV A,41H CJNE A,51H,KK MOV A,42H CJNE A,52H,KK MOV A,43H CJNE A,53H,KK MOV A,44H CJNE A,54H,KK CLR P2.4 MOV B,#100 PR:LCALL DELAY DJNZ B,PR SETB P2.4 PT:RET ;************************************输入密码时并显示*************************** KK: MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE10 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE5 LCALL WRITE1 MOV B ,#50 CLR P2.5 PK: LCALL DELAY DJNZ B,PK SETB P2.5 RET ;************************************修改密码操作部分****************************** XG_PASS: MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE9 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE8 LCALL WRITE1 MOV B ,#5 MOV R0,#30H YT: CLR P2.6 ACALL KEY SETB P2.6 MOV @R0,A INC R0 DJNZ B,YT ACALL KEY CJNE A,#12H,XT MOV A,30H CJNE A,50H,TK MOV A,31H CJNE A,51H,TK MOV A,32H CJNE A,52H,TK MOV A,33H CJNE A,53H,TK MOV A,34H CJNE A,54H,TK MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE9 LCALL WRITE1 MOV P0,#0C0H LCALL ENABLE MOV DPTR,#TABLE7 LCALL WRITE1 MOV B,#5 MOV R0,#50H XT1:CLR P2.7 ACALL KEY SETB P2.7 MOV @R0,A INC R0 DJNZ B,XT1 ACALL KEY CJNE A,#12,XT MOV P0,#80H ACALL ENABLE MOV DPTR,#TABLE1 LCALL WRITE1 MOV P0,#0C0H ACALL ENABLE MOV DPTR,#TABLE0 LCALL WRITE1 XT: RET TK: CLR P2.5 MOV B,#50 GK:LCALL DELAY DJNZ B,GK SETB P2.5 RET ;*************************************写数据************************************************** WRITE1:MOV R1,#00H A1: MOV A,R1 MOVC A,@A+DPTR LCALL WRITE2 INC R1 CJNE A,#00H,A1 RET WRITE2:MOV P0,A SETB RS CLR RW CLR E LCALL DELAY SETB E RET DELAY: MOV R7,#255 D1: MOV R6,#255 D2: DJNZ R6,D2 DJNZ R7,D1 RET TABLE10:DB 20H,50H,41H,53H,53H,57H,4FH,52H,44H,20H,45H,52H,52H,4FH DB 52H,21H,00H ;PASSWORD ERROR! TABLE9: DB 20H,49H,4EH,50H,55H,54H,20H,20H,20H,20H,54H,48H,45H,20H DB 20H,20H,00H ;INPUT THE TABLE8: DB 20H,4FH,4CH,44H,20H,20H,70H,41H,53H,53H,57H,4FH,52H,44H DB 20H,20H,00H ;OLD PASSWORD TABLE7: DB 20H,4EH,45H,57H,20H,20H,50H,41H,53H,53H,57H,4FH,52H,44H DB 20H,20H,00H ;NEW PASSWORD TABLE6: DB 20H,53H,48H,55H,20H,20H,52H,55H,20H,20H,20H,4DH,49H,20H DB 4DH,41H,00H ;输入密码行 TABLE5: DB 20H,20H,20H,2AH,20H,2AH,20H,2AH,20H,2AH,20H,2AH,20H,20H DB 20H,20H,00H ;空白行 TABLE4: DB 20H,53H,45H,54H,20H,20H,70H,41H,53H,53H,57H,4FH,52H,44H DB 20H,20H,00H ;设置密码 TABLE3: DB 38H,30H,35H,31H,20H,20H,20H,50H,41H,53H,53H,57H,4FH,52H DB 44H,20H,00H ;开始第一行8051 PASSWORD TABLE2: DB 20H,41H,20H,20H,4FH,52H,20H,20H,42H,20H,20H,4BH,45H,59H DB 20H,20H,00H ;开始第二行A OR B KEY 选择状态 TABLE1: DB 20H,20H,20H,20H,50H,41H,53H,53H,57H,47H,52H,44H,20H,20H DB 20H,20H,00H ;显示PASSWORD TABLE0: DB 20H,20H,58H,49H,55H,20H,20H,47H,41H,49H,20H,20H,50H,41H DB 53H,53H,00H END