5.3 单键扩充程序
以下是单键扩充成命令字符串的程序内容:
cseg segment
assume cs:cseg,ds:cseg
org 100h
Start:
jmp Initialize
Old_Keyboard_IO dd ?
assume ds:nothing
New_Keyboard_IO proc far
sti
cmp ah,0 ;Is this call a read request?
je ksRead
cmp ah,1 ;Is it a status request?
je ksStat ;Let original routine
jmp Old_Keyboard_IO ;handle remianing subfunction
ksRead:
call KeyRead ;Get next character to return
iret
ksStat:
call KeyStat ;Return appropriate status
ret 2 ;Important!!!
New_Keyboard_IO endp
KeyRead Proc near
cmp cs:current,0
jne ExpandChar
ReadChar:
mov cs:current,0 ;Slightly peculiar
pushf ;Let original routine
call Old_Keyboard_IO ;Determine keyboard status
cmp al,0
je Extended
ReadDone:
ret
Extended:
cmp ah,59 ;Is this character to expand?
jne ReadDone ;If not,return it normally
;If so,start expanding
mov cs:current,offset String
ExpandChar:
push si
mov si,cs:current
mov si,cs:[si]
inc cs:current
pop si
cmp al,0 ;Is this end of string?
je ReadChar ;If so,then read a real char?
ret
KeyRead endp
KeyStat proc near
cmp cs:current,0
jne FakeStat
pushf ;Let original routine
call Old_Keyboard_IO ;Determine keyboard
ret
FakeStat:
mov bx,1 ;Fake a "Character ready" by clearing ZF
cmp bx,0
ret
KeyStat endp
current dw 0
string db ''masm macro;'',0dh
db ''link macro;'',0dh
db ''exe2bin macro.exe macro.com'',0dh,0
Initialize:
assume cs:cseg,ds:cseg
mov bx,cs
mov ds,bx
mov al,16h
mov ah,35h
int 21h
mov word ptr Old_Keyboard_IO,bx
mov word ptr Old_Keyboard_IO,es
mov dx,offset New_Keyboard_IO
mov al,16h
mov ah,25h
int 21h
mov dx,offset Initialize
int 27h
cseg ends
end Start
5.4 一般的键盘扩充程序Mactab.asm
以下和程序可以把由表的查询,将任意娄的扩充键扩充成命令字符串:
cseg segment
assume cs:cseg,ds:cseg
org 100h
Start:
jmp Initialize
Old_Keyboard_IO dd ?
assum