e ds:nothing
cmp byte ptr cs:[si],0 ;end of table
je ReadDone
cmp ah,cs:[si]
je StartExpand
add si,3
jmp NextExt
StartExpand:
add si,1
push bx
mov bx,cs:[si]
mov cs:current,bx
pop bx
ExpandChar:
mov si,cs:current
mov al,cs:[si]
inc cs:current
cmp al,0 ;end of string 2
je ReadChar ;then read real char
ReadDone:
pop si
ret 3
KeyRead endp
current dw 0
KeyTab db 59
dw dir_cmd
db 60
dw dir_wide
db 61
dw dir_asm
db 62
dw dir_com
db 63
dw dir_exe
db 50
dw make_macro
db 0 ;This must be last in key table
dir_cmp db ''DIR'',0dh,0
dir_wide db ''DIR/W'',0dh,0
dir_asm db ''DIR *.ASM'',0dh,0
dir_com db ''DIR *.COM'',0dh,0
dir_exe db ''DIR *.EXE'',0dh,0
make_macro db ''MASM MACRO;'',0dh,0
db ''LINK MACRO;'',0dh,0
db ''EXE2BIN MACRO.EXE MACRO.COM'',0dh,0
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
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
;Read a character from the keyboard input queue,
;if not expanding or the expansion string.
;if expansion is in progress
KeyRead proc
cmp cs:current,0
jne ExpandChar
ReadChar:
mov cs:current,0 ;Slightly peculiar
pushf ;Let original routine
call Old_Keyboard_IO ;Get keyboard status
cmp al,0
je Extended
ReadDone:
ret
Expanded:
cmp ah,59 ;Is this character to expand?
jne ReadDone ;If not,then return it normally
;If so,then start expanding
mov cs:current,offset string
ExpandChar:
push si
mov si,cs:current