. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验15代码和注释  [待解决] 回复[ 1次 ]   点击[ 620次 ]  
ruder
[帖 主]   [ 发表时间:2011-01-26 19:53 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-01-02 12:37
assume cs:code

code segment
old:
  dw 0, 0                                ;用于保存原中断地址
color:
  push es
  push ax
  push bx
  push cx
  
  in al, 60h
  cmp al, 1eh + 80h
  jne def
  mov ax, 0b800h
  mov es, ax
  xor bx, bx
  mov cx, 4000
s:
  mov byte ptr es:[bx], 'A'
  inc bx
  mov byte ptr es:[bx], 1100b
  inc bx
  loop s
def:
  pushf
  call dword ptr cs:[200h]

  pop cx
  pop bx
  pop ax
  pop es
  iret

main:
  xor ax, ax                             ;保存原中断
  mov es, ax
  mov ax, es:[9 * 4]
  mov cs:[0], ax
  mov ax, es:[9 * 4 + 2]
  mov cs:[2], ax

  mov ax, cs                             ;安装新中断代码
  mov ds, ax
  mov di, 200h
  mov si, offset old
  mov cx, offset main - offset old
  cld
  rep movsb

  cli                                    ;更改中断
  mov word ptr es:[9 * 4], 204h
  mov word ptr es:[9 * 4 + 2], 0
  sti

  mov ax, 4c00h                          ;退出
  int 21h
code ends
end main
ruder
[第1楼]   [ 回复时间:2013-05-13 17:24 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-01-02 12:37
assume cs:code, ss:stack

stack segment
    db 080h dup (0)
stack ends

code segment
start:
    mov     ax, stack
    mov     ss, ax
    mov     sp, 080h

    push    cs
    pop     ds
    mov     si, offset new_int9
    xor     ax, ax
    mov     es, ax
    mov     di, 0204h
    mov     cx, offset new_int9_end - offset new_int9
    cld
    rep     movsb

    push    es:[9 * 4].0
    pop     es:[0200h].0
    push    es:[9 * 4].2
    pop     es:[0200h].2
    cli
    mov     word ptr es:[9 * 4].0, 0204h
    mov     word ptr es:[9 * 4].2, 0h
    sti

    mov     ax, 04c00h
    int     021h

new_int9:
    push    ds
    push    ax
    push    si
    in      al, 060h
    pushf
    call    dword ptr cs:[0200h]
    cmp     al, 09eh
    jne     new_int9_exit
    mov     ax, 0b800h
    mov     ds, ax
    xor     si, si
new_int9_again:
    mov     byte ptr ds:[si].0, 'A'
    add     si, 2
    cmp     si, 0fa0h
    jb      new_int9_again
new_int9_exit:
    pop     si
    pop     ax
    pop     ds
    iret
new_int9_end:
    nop
code ends

end start
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved