CDOE SEGMENT ;BJ.ASM
ASSUME CS:CODE
IOCONPT EQU 0FFEBH
IOBPT EQU 0FF29H
IOAPT EQU 0FF28H
PA EQU 0FF20H ;字位口
PB EQU 0FF21H ;字形口
PC EQU 0FF22H ;键入口
ORG 1630H
START: JMP START0
BUF BD ?,?,?,?,?,?
KZ DB ?
LTIME DB ?
LKEY DB ?
DATA1:
DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83,0C6H,0ALH ; 相序表正
DB 86H,8EH,0FFH,0CH,89H,0DEH,0C7H,8CH,0F3H,0BFH,8FH,0F1H ; 相序表反
START0: CALL BUF1
MOV AL,88H
MOV DX,IOCONPT
OUT DX,AL 初始化 8255
REDIKEY: CALL DISPKEY
CMP KZ,01H
JZ ZZ
CMP KZ,02H
JZ FZ
CMP KZ,03H
JZ STX
JMP REDIKEY
STX: JMP ST
ZZ: CALL BUFZ
ZZ1: MOV DX,IOAPT
MOV AL,03H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,06H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,0CH
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,O9H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,O3H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,06H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,0CH
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
MOV AL,09H
MOV DX,IOAPT
OUT DX,AL
CALL DELPZ
JMP ZZ1
;--------------------------------------------------------
FZ: CALL BUFF
FZ1: MOV DX,IOAPT
MOV AL,0CH
OUT DX,AL
CALL DELPF
MOV AL,06H
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
MOV DX,IOAPT
MOV AL,03H
OUT DX,AL
CALL DELPF
MOV AL,09H
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
MOV AL,0CH
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
MOV AL,06H
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
MOV AL,03H
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
MOV AL,09H
MOV DX,IOAPT
OUT DX,AL
CALL DELPF
JMP FZ1
;------------------------------------------
ST: CALL BUFS
MOV DX,IOAPT
MOV AL,00H
OUT DX,AL
ST1: CALL DISPKEY
CMP KZ,01H
JZ ZZMON
CMP KZ,02H
JZ FZMON
JMP ST1
DELPZ: MOV CX,02H
CON1: PUSH CX
CALL DISPKEY
POP CX
CMP KZ,02H
JZ FZMON
CMP KZ,03H
JZ STMON
LOOP CON1
RET
DELPF: MOV CX,02H
CON2: PUSH CX
CALL DISPKEY
POP CX
CMP KZ,01H
JZ ZZMON
CMP KZ,03H
JZ STMON
LOOP CON2
RET
ZZMON: POP CX
JMP ZZ
FZMON: POP CX
JMP ZZ
FZMON: POP CX
JMP FZ
STMON: POP CX
JMP ST
;------------------------------------------
DISPKEY: CALL DISP
CALL KEY
MOV AH,AL ;newkey
MOV BL,LTIME ;ltime
MOV BH,LKEY ;lkey
MOV AL,01H
MOV DX,PA ;0ff21h
OUT DX,AL
CMP AH,BH
MOV BH,AH ;bh=new key
MOV AH,BL ;al=time
JZ DISK4
MOV BL,88H
MOV AH,88H
DISK4: DEC AH
CMP AH,82H
JZ DISK6
CMP AH,0EH
JZ DISK6
CMP AH,00H
JZ DISK5
MOV AH,20H
DEC BL
JMP DISK7
DISK5: MOV AH,0FH
DISK6: MOV BL,AH
MOV AH,BH
DISHK7: MOV LTIME,BL
MOV LKEY,BH
MOV KZ,BH
MOV AL,AH
RET
KEY: MOV AL,0FFH
MOV DX,PB
OUT DX,AL
MOV BL,00H
MOV AH,0FEH
MOV CX,08H
KEY1: MOV AL,SH
MOV DX,PA
OUT DX,AL
ROL AL,01H
MOV AH,AL
NOP
NOP
NOP
NOP
NOP
NOP
MOV DX,PC
IN AL,DX
NOT AL
NOP
NOP
AND AL,0FH
JNZ KEY2
INC BL
LOOP KEY1
JMP NKEY
KEY2: TEST AL,01H
JE KEY3
MOV AL,00H
JMP KEY6
KEY3: TEST AL,02H
JE KEY4
MOV AL,08H
JMP KEY6
KEY4: TEST AL,04H
JE KEY5
MOV AL,10H
JMP KEY6
KEY5: TEST AL,08H
JE NKEY
MOV AL,18H
KEY6: ADD AL,BL
CMP AL,10H
JNC FKEY
MOV BL,AL
MOV BH,0H
MOV SI,OFFSET DATA2
MOV AL,[BX+SI]
RET
NKEY: MOV AL,20H
FKEY: RET
DATA2: DB 07H,04H,08H,05H,09H,06H,0AH,0BH
DB 01H,00H,02H,0FH,03H,0EH,0CH,0DH
DISP: MOV AL,0FFH ;00H
MOV DX,PA
OUT DX,AL
MOV CL,0DFH ;20H;显示子程序,5ms
MOV BX,OFFSET BUF
DIS1: MOV AL,[BX]
MOV AH,00H
PUSH BX
MOV BX,OFFSET DATA1
ADD BX,AX
MOV AL,[BX]
POP BX
MOV DX,PB
OUT DX,AL
MOV AL,CL
MOV DX,PA
OUT DX,AL
PUSH CX
DIS2: MOV CX,0A0H
LOOP $
POP CX
CMP CL,0FEH
JZ LX1
INC BX
ROR CL,1
JMP DIS1
LX1: MOV AL,0FFH
MOV DX,PB
OUT DX,AL
RET
BUF1: MOV BUF,0BH
MOV BUF+1,019H
MOV BUF+2,17H
MOV BUF+3,17H
MOV BUF+4,17H
MOV BUF+5,17H
RET
BUFZ: MOV BUF,0BH
MOV BUF+1,19H
MOV BUF+2,17H
MOV BUF+3,17H
MOV BUF+4,17H
MOV BUF+5,0FH
RET
BUFF: MOV BUF,0BH
MOV BUF+1,19H
MOV BUF+2,17H
MOV BUF+3,17H
MOV BUF+4,17H
MOV BUF+5,18H
RET
BUFS: MOV BUF,0BH
MOV BUF+1,19H
MOV BUF+2,17H
MOV BUF+3,17H
MOV BUF+4,17H
MOV BUF+5,05H
RET
CODE ENDS
END START
|