当前位置: 网学 > 编程文档 > 汇编语言 > 正文

用汇编编写DOS下的内存驻留程序(5):键盘输入扩充程序

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/18
下载{$ArticleTitle}原创论文样式
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
 

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号