⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dazi.txt

📁 用汇编语言设计键盘打字程序
💻 TXT
字号:
;-----------------宏定义------------------

;--清屏宏定义-----------------------------
clear_screen macro op1,op2,op3,op4
      mov     ah,06h
      mov     al,00h
      mov     bh,07h
      mov     ch,op1
      mov     cl,op2
      mov     dh,op3
      mov     dl,op4
      int     10h
      mov     ah,02h
      mov     bh,00h
      mov     dh,00h
      mov     dl,00h
      int     10h
endm
;-----------------------------------------
;--移动光标-------------------------------
move_cur macro x,y
      mov   ah,02h
      mov   dh,x
      mov   dl,y
      mov   bh,00h
      int   10h
endm
;-----------------------------------------
;--字符串输出-----------------------------
str_print macro x,y,addr_str
      mov   ah,02h
      mov   bh,00h
      mov   dh,x
      mov   dl,y
      int   10h
      mov   ah,09h
      lea   dx,addr_str
      int   21h
endm
;-----------------------------------------
;-----------------------------------------
stack segment     para  stack 'stack'

      db    64 dup(?)

stack ends
;-----------------------------------------
data  segment
      str_welcome db 'WELCOME TO PLAY$'
      str_copy    db 'Edit:leiyuming 20054973$'
      str_data    db 'date:2008/1/5$'
      str_message db 'press Enter key to continue.......$'
      str_quit    db 'press ESC to quit.$'
      str_letter  db 'asdfghjkl;zxcvbnm,./$'
      str_tip_1   db 'press ESC to back$'
      str_tip_2   db ''
      str_warn_1  db 'you press a wrong key.$'
      buffer      db 100 dup(0)
      buffer_ip   db    0
      
      cur_position      db    2 dup(?)
      
      old_cs      dw    ?
      old_ip      dw    ?
      
      wrong       db  0             ;按下了多少次退格键
      
data  ends
;-----------------------------------------
code  segment
      assume      cs:code,ds:data,ss:stack
      ;--主程序------------------
main  proc
start:
      mov   ax,data
      mov   ds,ax
      clear_screen 00d,00d,24d,79d

      str_print 05d,15d,str_welcome
      str_print 07d,15d,str_copy
      str_print 09d,15d,str_data
      str_print 11d,15d,str_message
      str_print 013d,15d,str_quit
      
      mov   ah,01h            ;从键盘输入任意字符
      int 21h
      cmp   al,00011011b
      jz    exit              ;是ESC键被按下,退出
      
      clear_screen 00d,00d,24d,79d
      
      mov ah,35h               ;获取键盘中服地址
      mov al,09h
      int 21h
      mov old_cs,es
      mov old_ip,bx

      push ds                  ;修改键盘中服地址
      mov dx,seg kbint
      mov ds,dx
      mov dx,offset kbint
      mov al,09h
      mov ah,25h
      int 21h
      pop ds
      
      sti

      str_print 00d,20d,str_tip_1
      str_print 02d,01d,str_letter
      move_cur  03d,01d
      mov   ah,09h
      int   21h
      
;q:    jmp   q
exit:
      push ds
      mov dx,old_ip
      mov ax,old_cs
      mov ds,ax
      mov al,09h
      mov ah,25h
      int 21h
      pop ds
      mov ah,4ch              ;程序退出
      int 21h
main  endp
;------------------------------------------
;--键盘输入调用----------------------------
kbint proc  near
      push  ax                ;寄存器保护
      push  bx

kbint_exit:
      pop   bx
      pop   ax
      iret
kbint endp


code  ends
end   start



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -