问题描述
- 求大神帮看看这段汇编代码
-
学校课程设计,这段是步进电机的控制代码,用键盘输入,在六位LED七段数码显示管上显示,求大神把下面代码加上注释,实在不行就帮忙看下键盘显示那部分是怎么回事,有重谢。ORG 0A30H ;?
MONIT: MOV SP,#50H
MOV 7EH,#00H
MOV 7DH,#02H
MOV R0,#7CH
MOV A,#08H
MOV R4,#04H
MONIT1: MOV @R0,A
DEC R0
DJNZ R4,MONIT1
MOV A,#7EH
MOV DPTR,#1FFFH ;DISPFLAG
MOVX @DPTR,A
MOV 76H,#00H
MOV 77H,#00H
KEYDISP0:LCALL KEY
JC DATAKEY
AJMP MONIT2
DATAKEY:LCALL DATAKEY1
DB 79H,7EH
SJMP KEYDISP0MONIT2: CJNE A,#16H,KEYDISP0
LCALL DISP
MOV A,7AH
ANL A,#0FH
SWAP A
ADD A,79H
MOV R6,A
MOV A,7CH
ANL A,#0FH
SWAP A
ADD A,7BH
MOV R7,A
MOV A,7EH
CJNE A,#00H,MONIT4
MONIT3: MOV P1,#03H
LCALL DELAY0
LCALL MONIT5
MOV P1,#06H
LCALL DELAY0
LCALL MONIT5
MOV P1,#0CH
LCALL DELAY0
LCALL MONIT5
MOV P1,#09H
LCALL DELAY0
LCALL MONIT5
SJMP MONIT3
MONIT4: MOV P1,#09H
LCALL DELAY0
LCALL MONIT5
MOV P1,#0CH
LCALL DELAY0
LCALL MONIT5
MOV P1,#06H
LCALL DELAY0
LCALL MONIT5
MOV P1,#03H
LCALL DELAY0
LCALL MONIT5
SJMP MONIT4
MONIT5: DEC R6
CJNE R6,#0FFH,MONIT6
DEC R7
CJNE R7,#0FFH,MONIT6
LJMP MONIT
MONIT6: LCALL MONIT7
RETMONIT7: MOV R0,#79H
MOV A,R6
LCALL MONIT8
MOV A,R7
LCALL MONIT8
LCALL DISP
RET
MONIT8: MOV R1,A
ACALL MONIT9
MOV A,R1
SWAP A
MONIT9: ANL A,#0FH
MOV @R0,A
INC R0
RET
DELAY0: MOV R0,#7DH
MOV A,@R0
SWAP A
MOV R4,A
DELAY1: MOV R5,#80H
DELAY2: DJNZ R5,DELAY2
LCALL DISP
DJNZ R4,DELAY1 ;***
RETDATAKEY1:MOV R4,A
MOV DPTR,#1FFFH
MOVX A,@DPTR
MOV R1,A
MOV A,R4
MOV @R1,A
CLR A
POP 83H
POP 82H
MOVC A,@A+DPTR
INC DPTR
CJNE A,01H,DATAKEY3
DEC R1
CLR A
MOVC A,@A+DPTR
DATAKEY2:PUSH 82H
PUSH 83H
MOV DPTR,#1FFFH
MOVX @DPTR,A
POP 83H
POP 82H
INC DPTR
PUSH 82H
PUSH 83H
RET
DATAKEY3:DEC R1
MOV A,R1
SJMP DATAKEY2KEY0: MOV R6,#20H
MOV DPTR,#1FFFH
MOVX A,@DPTR
MOV R0,A
MOV A,@R0
MOV R7,A
MOV A,#10H
MOV @R0,A
KEY3: LCALL KEYDISP
JNB 0E5H,KEY2
DJNZ R6,KEY3
MOV DPTR,#1FFFH ;***
MOVX A,@DPTR
MOV R0,A ;***
MOV A,R7
MOV @R0,A
KEY: MOV R6,#50H
KEY1: LCALL KEYDISP
JNB 0E5H,KEY2 ;***
DJNZ R6,KEY1
SJMP KEY0
KEY2: MOV R6,A
MOV A,R7
MOV @R0,A
MOV A,R6 ;A=KEYDATA
KEYEND: RETKEYDISP:LCALL DISP
LCALL KEYSM
MOV R4,A ;KEYDATA
MOV R1,#76H ;DATASAME TIME
MOV A,@R1
MOV R2,A
INC R1
MOV A,@R1
MOV R3,A ;LAST KEYDATA
XRL A,R4
;TWO TIME KEYDATA
MOV R3,04H ;NEW KEYDATA---R3
MOV R4,02H ;TIME---R4
JZ KEYDISP1
MOV R2,#88H
MOV R4,#88H
KEYDISP1:DEC R4
MOV A,R4
XRL A,#82H
JZ KEYDISP2
MOV A,R4 ;R4=TIME
XRL A,#0EH
JZ KEYDISP2
MOV A,R4
ORL A,R4
JZ KEYDISP3
MOV R4,#20H ;R4=20H
DEC R2
LJMP KEYDISP5
KEYDISP3:MOV R4,#0FH
KEYDISP2:MOV R2,04H
MOV R4,03H
KEYDISP5:MOV R1,#76H
MOV A,R2
MOV @R1,A
INC R1
MOV A,R3
MOV @R1,A
MOV A,R4 ;****
CJNE R3,#10H,KEYDISP4
KEYDISP4:RETDISP: SETB 0D4H
MOV R1,#7EH
MOV R2,#20H
MOV R3,#00H
DISP1: MOV DPTR,#0FF21H
MOV A,R2
MOVX @DPTR,A
MOV DPTR,#DATA1
MOV A,@R1
MOVC A,@A+DPTR
MOV DPTR,#0FF22H
MOVX @DPTR,A
DISP2: DJNZ R3,DISP2
DEC R1
CLR C
MOV A,R2
RRC A
MOV R2,A
JNZ DISP1
MOV A,#0FFH
MOV DPTR,#0FF22H
MOVX @DPTR,A
CLR 0D4H
RET
DATA1: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
DB 88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,0DEHKEYSM: SETB 0D4H
MOV A,#0FFH
MOV DPTR,#0FF22H
MOVX @DPTR,A ;OFF DISP
KEYSM0: MOV R2,#0FEH
MOV R3,#08H
MOV R0,#00H
KEYSM1: MOV A,R2
MOV DPTR,#0FF21H
MOVX @DPTR,A
NOP
RL A
MOV R2,A
MOV DPTR,#0FF23H
MOVX A,@DPTR
CPL A
NOP
NOP
NOP
ANL A,#0FH
JNZ KEYSM2
INC R0 ;NOKEY
DJNZ R3,KEYSM1
SJMP KEYSM10
KEYSM2: CPL A ;YKEY
JB 0E0H,KEYSM3
MOV A,#00H
SJMP KEYSM7
KEYSM3: JB 0E1H,KEYSM4
MOV A,#08H
SJMP KEYSM7
KEYSM4: JB 0E2H,KEYSM5
MOV A,#10H
SJMP KEYSM7
KEYSM5: JB 0E3H,KEYSM10
MOV A,#18H
KEYSM7: ADD A,R0
CLR 0D4H
CJNE A,#10H,KEYSM9
KEYSM9: JNC KEYSM10
MOV DPTR,#DATA2
MOVC A,@A+DPTR
KEYSM10:RET
DATA2: DB 07H,04H,08H,05H,09H,06H,0AH,0BH
DB 01H,00H,02H,0FH,03H,0EH,0CH,0DH
END