;;;;;;;;;;;;;;;;;;;;;;;;;;;端口定义;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CSA EQU p2.4
CSB EQU p2.3
rs EQU P2.2
rw EQU P2.1
E EQU P2.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;单元定义;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
COM EQU 21H
DAT EQU 22H
column EQU 23H
pagef EQU 24h
cpage EQU 25H
ccolumn EQU 26H
codes EQU 27h
column2 EQU 28H
pagef2 equ 29h
cpage2 EQU 2aH
ccolumn2 EQU 2bH
column3 EQU 2eH
pagef3 equ 2fh
cpage3 EQU 30H
ccolumn3 EQU 31H
column4 EQU 32H
pagef4 equ 33h
cpage4 EQU 34H
ccolumn4 EQU 35H
column5 EQU 36H
pagef5 equ 37h
cpage5 EQU 38H
ccolumn5 EQU 39H
ORG 0
LJMP START
START:MOV SP,#60H
LCALL INT ;调用初始化子程序
START1:LCALL CLEAR ;调用清屏子程序
;*********************************固定字符显示
mov column3,#0
mov pagef3,#0
mov codes,#0
lcall writeleft2
mov column3,#0
mov pagef3,#4
mov codes,#2
lcall writeleft2
mov column3,#16
mov pagef3,#4
mov codes,#3
lcall writeleft2
mov column3,#16
mov pagef3,#0
mov codes,#1
lcall writeleft2
mov column,#32
mov pagef,#0
mov codes,#1
lcall writeleft
mov column3,#0
mov pagef3,#2
mov codes,#0
lcall writeleft2
mov column,#40
mov pagef,#2
mov codes,#15
lcall writeleft
mov column,#40
mov pagef,#0
mov codes,#15
lcall writeleft
mov column3,#16
mov pagef3,#2
mov codes,#1
lcall writeleft2
mov column,#32
mov pagef,#2
mov codes,#2
lcall writeleft
MOV R0,#0
MOV R1,#255
QQQ:MOV @R0,#0
INC R0
DJNZ R1,QQQ
;************************************固定字符显示结束,键盘扫描开始
dd:mov r0,#0f7h
mov r1,#0
cc:mov a,r0
mov p1,a
mov a,p1
mov r2,a
setb c
mov r3,#4
bb:rlc a
jnc aa
ee:inc r1
djnz r3,bb
mov a,r0
setb c
rrc a
mov r0,a
jc cc
ljmp dd
KAOO:LJMP KAO
BBB2:LJMP BB2
aa:lcall mm
mov a,p1
xrl a,r2
jnz ee
ff:mov a,p1
xrl a,r2
jz ff
MOV A,51H
CJNE A,#1,BBB2 ;键盘扫描结束,加法运算开始
MOV A,R1
CJNE A,#14,KAOO
MOV 47H,R1
LCALL A31
MOV A,40H
ADD A,60H
MOV B,#10
DIV AB
MOV 40H,B
ADD A,41H
ADD A,71H
MOV B,#10
DIV AB
MOV 41H,B
ADD A,42H
ADD A,72H
MOV B,#10
DIV AB
MOV 42H,B
ADD A,44H
ADD A,74H
MOV B,#10
DIV AB
MOV 44H,B
ADD A,45H
ADD A,75H
MOV B,#10
DIV AB
MOV 45H,B
ADD A,46H
ADD A,76H
MOV B,#10
DIV AB
MOV 46H,B
ADD A,48H
ADD A,78H
MOV B,#10
DIV AB
MOV 48H,B
ADD A,49H
ADD A,79H
MOV B,#10
DIV AB
MOV 49H,B
MOV 0CEH,A
CJNE A,#0,CC0
MOV A,49H
CJNE A,#0,CC1
MOV A,48H
CJNE A,#0,CC2
MOV A,46H
CJNE A,#0,CC3
MOV A,45H
CJNE A,#0,CC4
MOV A,44H
CJNE A,#0,CC5
MOV A,42H
CJNE A,#0,CC6
MOV A,41H
CJNE A,#0,CC7
MOV A,40H
CJNE A,#0,CC8
CC0:LCALL A08
CC1:LCALL A07
CC2:LCALL A06
CC3:LCALL A05
CC4:LCALL A04
CC5:LCALL A03
CC6:LCALL A02
CC7:LCALL A01
CC8:LCALL A00
LJMP DD
KAO:CJNE A,#15,KAO1
LJMP START1
KAO1:MOV A,50H
CJNE A,#0,A1A1
MOV 60H,R1
LCALL A8
INC 50H
ljmp dd
A1A1:CJNE A,#1,A1A2
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
INC 50H
LJMP DD
A1A2:CJNE A,#2,A1A3
MOV 72H,71H
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
LCALL A10
INC 50H
LJMP DD
A1A3:CJNE A,#3,A1A5
MOV 74H,72H
MOV 72H,71H
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
LCALL A10
LCALL A11
INC 50H
LJMP DD
A1A5:CJNE A,#4,A1A6
MOV 75H,74H
MOV 74H,72H
MOV 72H,71H
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
LCALL A10
LCALL A11
LCALL A12
INC 50H
LJMP DD
A1A6:CJNE A,#5,A1A7
MOV 76H,75H
MOV 75H,74H
MOV 74H,72H
MOV 72H,71H
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
LCALL A10
LCALL A11
LCALL A12
LCALL A13
INC 50H
LJMP DD
A1A7:CJNE A,#6,A1A9
MOV 78H,76H
MOV 76H,75H
MOV 75H,74H
MOV 74H,72H
MOV 72H,71H
MOV 71H,60H
MOV 60H,R1
LCALL A8
LCALL A9
LCALL A10
LCALL A11
LCALL A12
LCALL A13
LCALL A14
INC 50H
LJMP DD
A1A9:CJNE A,#7,A1A10
MOV 79H,78H
MOV 78H,76H
MOV 76H,75H