9號中斷:按下f3鍵,將從b8000h處開始的4000個字節複製到20000h處,按下f8鍵,將從20000h處開始的4000個字節複製到b8000h處。

 

; 編寫9號中斷處理程序,該程序在原來9號中斷處理程序的基礎上新增如下功能:
;  a:按下f3鍵,將從b8000h處開始的4000個字節複製到20000h處。
;  b:按下f8鍵,將從20000h處開始的4000個字節複製到b8000h處。
; 注:以上9號中斷處理程序需要被安裝程序安裝在安全區域,安裝完畢後安裝程序結束。
assume cs:code
stack segment
db 128 dup (0)
stack ends
code segment
start:mov ax,stack
      mov ss,ax
      mov sp,128
      push cs
      pop ds
      mov ax,0
      mov es,ax
      mov si,offset int9          ;安裝程序
      mov di,204h
      mov cx,offset int9end-offset int9
      cld
      rep movsb

      push es:[9*4]           ;保存原來int9在中斷向量表的入口地址
      pop es:[200h]
      push es:[9*4+2]
      pop es:[202h]

      cli
      mov word ptr es:[9*4],204h  ;將新的int9入口地址添加到中斷向量表
      mov word ptr es:[9*4+2],0
      sti
      mov ax,4c00h
      int 21h

int9:push ax
     push di
     push si
     push ds
     push es
     push cx

     in al,60h    ;從60H號端口讀出鍵盤輸入

     pushf
     call dword ptr cs:[200h] ;調用原來的int9
    
      cmp al,3dh    ;F3的掃描碼
      jne next
      mov ax,0b800h
      mov ds,ax
      mov si,0

      mov ax,2000h
      mov es,ax
      mov di,0
      mov cx,4000
      cld
      rep movsb

 next:cmp al,40h  ;F6的掃描碼
      jne return
     
      mov ax,2000h
      mov ds,ax
      mov si,0

      mov ax,0b800h
      mov es,ax
      mov di,0

      mov cx,4000
      cld
      rep movsb

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章