比较转移指令的值写错了,正确的是:
LAB0:CJNE A,#01H,LAB1
LAB1:CJNE A,#02H,LAB2
LAB2:CJNE A,#04H,LAB3
LAB3:CJNE A,#08H,LAB4
LAB4:CJNE A,#10H,LAB5
LAB5:CJNE A,#20H,LAB6
LAB6:CJNE A,#40H,LAB7
LAB7:CJNE A,#80H,LOOP
硬件设计不够严谨,会造成5条指令期间,用户按键不响应。如果用中断来处理,就把不响应按键的时间减少到一个机器周期,可靠性提高。
ORG 0000H
MAIN:MOV P0,#0FFH
MOV P1,#0FFH
MOV P2,#0FFH
SETB P3.7
MOV P0,#0C0H ;显示0
JB P3.7,$
LCALL DELAY
JB P3.7,$
JNB P3.7,$
LCALL DELAY
JNB P3.7,$
MOV P0,#8CH ;显示P
LOOP:MOV P1,#0FFH
MOV A,P1
MOV P1,#0
XRL A,#0FFH
JZ LOOP
LAB0: CJNE A,#0FEH,LAB1
MOV P2,#0FEH
MOV P0,#0F9H ;
LJMP WAIT
LAB1:CJNE A,#0FDH,LAB2
MOV P2,#0FDH
MOV P0,#0A4H
LJMP WAIT
LAB2:CJNE A,#0FBH,LAB3
MOV P2,#0FBH
MOV P0,#0B0H
LJMP WAIT
LAB3:CJNE A,#0F7H,LAB4
MOV P2,#0F7H
MOV P0,#99H
LJMP WAIT
LAB4:CJNE A,#0EFH,LAB5
MOV P2,#0EFH
MOV A,#92H
LJMP WAIT
LAB5:CJNE A,#0DFH,LAB6
MOV P2,#0DFH
MOV A,#82H
LJMP WAIT
LAB6:CJNE A,#0BFH,LAB7
MOV P2,#0BFH
MOV P0,#0F8H
LJMP WAIT
LAB7:CJNE A,#7FH,LOOP
MOV P2,#7FH
MOV P0,#80H
LJMP WAIT
WAIT:LJMP $
DELAY:MOV R5,#5
L1: MOV R6,#250
L2: DJNZ R6,L2
DJNZ R5,L1
END