YJ EQU 50H
YJ1 EQU 51H
GONG EQU 52H
ORG 0000H
START: MOV R3,#00H
MOV GONG,#0
MOV 32H,#00H
MOV 33H,#00H
MOV 34H,#00H
MLOOP: CALL DISP
WAIT: CALL TESTKEY
NEXT1: CJNE A,#1,NEXT2
LJMP E1
NEXT2: CJNE A,#2,NEXT3
LJMP E1
NEXT3: CJNE A,#3,NEXT4
LJMP E1
NEXT4: CJNE A,#4,NEXT5
LJMP E1
NEXT5: CJNE A,#5,NEXT6
LJMP E1
NEXT6: CJNE A,#6,NEXT7
LJMP E1
NEXT7: CJNE A,#7,NEXT8
LJMP E1
NEXT8: CJNE A,#8,NEXT9
LJMP E1
NEXT9: CJNE A,#9,NEXT10
LJMP E1
NEXT10: CJNE A,#10,NEXT11
LJMP E2
NEXT11: CJNE A,#11,NEXT12
LJMP E2
NEXT12: CJNE A,#12,NEXT13
LJMP E2
NEXT13: CJNE A,#13,NEXT14
LJMP E2
NEXT14: CJNE A,#14,NEXT15
LJMP E2
NEXT15: LJMP E3
E1: CJNE R3,#1,N1
LJMP E11
N1: CJNE R3,#2,N2
LJMP E12
N2: CJNE R3,#3,N3
LJMP E13
N3: LJMP E3
E11: MOV R4,A
MOV 34H,A
MOV 33H,#00H
MOV 32H,#00H
LJMP MLOOP
E12: MOV R7,A
MOV B,#10
MOV A,R4
MUL AB
ADD A,R7
MOV R4,A
MOV 32H,#00H
MOV 33H,34H
MOV 34H,R7
LJMP MLOOP
E13: MOV R7,A
MOV B,#10
MOV A,R4
MUL AB
JB OV,E3
ADD A,R7
JB CY,E3
MOV R4,A
MOV 32H,33H
MOV 33H,34H
MOV 34H,R7
LJMP MLOOP
E3: MOV R3,#0
MOV R4,#0
MOV YJ,#0
MOV GONG,#0
MOV 32H,#00H
MOV 33H,#00H
MOV 34H,#00H
LJMP MLOOP
E2: MOV 34H,#00H
MOV 33H,#00H
MOV 32H,#00H
MOV R0,GONG
MOV GONG,A
MOV A,R0
CJNE A,#10,N21
LJMP JIA ;??
N21: CJNE A,#11,N22
LJMP JIAN ;??
N22: CJNE A,#12,N23
LJMP CHENG ;??
N23: CJNE A,#13,N24
LJMP CHU ;??
N24: CJNE A,#0,N25
LJMP FIRST ;??????????
N25: LJMP DEN
N4: LJMP E3
FIRST: MOV YJ,R4
MOV R3,#0
LJMP DISP1
JIA: MOV A,YJ
ADD A,R4
JB CY,N4
MOV YJ,A
MOV R3,#0
LJMP DISP1
JIAN: MOV A,YJ
SUBB A,R4
JB CY,N4
MOV YJ,A
MOV R3,#0
LJMP DISP1
CHENG: MOV A,YJ
MOV B,A
MOV A,R4
MUL AB
JB OV,N4
MOV YJ,A
LJMP DISP1
CHU: MOV A,R4
MOV B,A
MOV A,YJ
DIV AB
MOV YJ,A
MOV R3,#0
LJMP DISP1
DEN: MOV R3,#0
LJMP DISP1
DISP1: MOV B,#10
MOV A,YJ
MOV B,#10
MOV A,YJ1
DIV AB
MOV YJ1,A
MOV A,B
MOV 33H,A
MOV A,YJ1
JZ DISP11
MOV 32H,A
DISP11: LJMP MLOOP
DISP: MOV R0,#34H
DIR1: MOV DPTR,#SEGTAB
MOV A,@R0
MOVC A,@A+DPTR
MOV P1,A
CJNE R0,#34H,DIR2
SETB P1.0
DIR2: CJNE R0,#33H,DIR3
SETB P1.1
CALL D1MS
CLR P1.1
DEC R0
SJMP DIR1
DIR3: SETB P1.2
CALL D1MS
CLR P1.2
RET
D1MS: MOV R7,#02H ;???
DMS: MOV R6,#0F0H
DJNZ R6,$
DJNZ R7,DMS
RET
SEGTAB: DB 0C0H,0F9H,0A4H,0B0H
DB 99H,92H,82H,0F8H
DB 80H,90H,88H,83H
DB 0C6H,0A1H,86H,8EH
TESTKEY: ACALL DISP
MOV P2,0FH
MOV A,P2
CPL A
ANL A,#0FH
RET
KEYTABLE: DB 0D7H,0EBH,0DBH,0BBH
DB 0EDH,0DDH,0BDH,0EEH
DB 0DEH,0BEH,077H,07BH
DB 07DH,07EH,0B7H,0E7H
GETKEY: MOV R6,#10
ACALL DELAY
MOV P1,#0FH
MOV A,P1
CJNE A,#0FH,K12
LJMP MLOOP
K12: MOV B,A
MOV P2,#0EFH
MOV A,P2
CJNE A,#0EFH,K13
MOV P1,#0DFH
MOV A,P2
CJNE A,#0DFH,K13
MOV P1,#0BFH
MOV A,P2
CJNE A,#0BFH,K13
MOV P2,#07FH
MOV A,P2
CJNE A,#07FH,K13
LJMP MLOOP
K13: ANL A,#0F0H
ORL A,B
MOV B,A
MOV R1,#16
MOV R2,#0
MOV DPTR,#KEYTABLE
K14: MOV A,R2
MOVC A,@A+DPTR
CJNE A,B,K16
MOV P2,#0FH
K15: MOV A,P2
CJNE A,#0FH,K15
MOV R6,#10
ACALL DELAY
MOV A,R2
RET
K16: INC R2
DJNZ R1,K14
AJMP MLOOP
DELAY: MOV R7,#10
TS1: MOV R6,#0FFH
TS2: NOP
NOP
DJNZ R6,TS2
DJNZ R7,TS1
RET
END
|