. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验15:安装9号中断以及取消9号中断  [待解决] 回复[ 13次 ]   点击[ 825次 ]  
cnhnyu
[帖 主]   [ 发表时间:2007-11-02 16:43 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2007-10-22 14:47
下面是我写的安装9号中断的程序,当输入a并松开的时候,显示满屏幕的'A',按其它键默认处理

; p62.asm
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]
                pop es:[200h]
                push es:[9*4+2]
                pop es:[202h]

                cli
                mov word ptr es:[9*4], 204h
                mov word ptr es:[9*4+2], 0
                sti

                mov ax, 4c00h
                int 21h

        int9:
                push ax
                push cx
                push si
                push es

                in al, 60h

                pushf
                call dword ptr cs:[200h]

                cmp al, 9eh
                jne int9ret

                mov ax, 0b800h
                mov es, ax
                xor si, si
                mov cx, 2000
        s:        mov byte ptr es:[si], 'A'
                add si, 2
                loop s
        int9ret:
                pop es
                pop si
                pop cx
                pop ax
                iret
        int9end:nop

code ends

end start

当安装了该中断之后,只要按'a'键,就会满屏幕的‘A’,如果你是在windows的dos窗口下运行该程序,那么你必须重新启动该窗口,否则你要是干其它的活,比如,你要继续用masm编译程序的话,是根本不可能的,所以,能安装,就能卸载,根据上面一个程序,我写了一个卸载程序,恢复原有的9号中断,不过,有一点要求,就是该程序的可执行文件不能含有字母'a',这样,你就可以随时安装,随时卸载了,下面是卸载程序:
assume cs:code

; p63.asm
; 清除p62.asm 安装的9号中断,恢复原有的9号中断
code segment
        start:
                mov ax, 0
                mov ds, ax

                cli
                mov ax, ds:[200h]
                mov ds:[9*4], ax
                mov ax, ds:[202h]
                mov ds:[9*4+2], ax
                sti

                mov ax, 4c00h
                int 21h

code ends

end start
happy
[第1楼]   [ 回复时间:2007-11-02 21:04 ]   [引用]   [回复]   [ top ] 
荣誉值:32
信誉值:0
注册日期:2007-07-14 19:06
好,学的不错!鼓励一下!
iceviewer
[第2楼]   [ 回复时间:2007-11-09 14:33 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:6
注册日期:2007-10-11 10:24
请问运行环境是?我在WINXP SP2下面怎么执行都不成功阿。。。,代码几乎一样
lxjjoinly
[第3楼]   [ 回复时间:2007-11-10 08:38 ]   [引用]   [回复]   [ top ] 
荣誉值:5
信誉值:3
注册日期:2007-11-05 21:15
我也是啊,没反映,郁闷,倒是在调试的时候DOS窗口死掉了。。。。
cnhnyu
[第4楼]   [ 回复时间:2007-11-21 16:59 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2007-10-22 14:47
这两个程序都是在windows xp sp的command.com窗口下运行的,没有问题
taotling
[第5楼]   [ 回复时间:2008-03-08 02:36 ]   [引用]   [回复]   [ top ] 
荣誉值:53
信誉值:0
注册日期:2008-02-09 02:55
嗯,就是别在使用第一个程序前使用。
liurong001
[第6楼]   [ 回复时间:2008-06-27 06:45 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-06-16 23:40
不行哦。我也试了的。在SP2下根本无法运行,楼主的程序我也试了。
mess
[第7楼]   [ 回复时间:2008-06-27 09:12 ]   [引用]   [回复]   [ top ] 
荣誉值:337
信誉值:0
注册日期:2008-01-01 17:48
我记得书上有提示,涉及键盘的程序要到实dos下运行,虚拟dos下可能显示的效果不一样或是出错。
cx_jin
[第8楼]   [ 回复时间:2008-07-10 11:10 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:2
注册日期:2008-06-04 13:41
第4楼的cnhnyu说的没错,在command.com窗口下运行可以。
yugong
[第9楼]   [ 回复时间:2008-10-26 21:41 ]   [引用]   [回复]   [ top ] 
荣誉值:2
信誉值:8
注册日期:2008-09-15 09:10
请问 int9: 
        push ax 
        push cx 
        push si 
        push es 

        in al, 60h 

        pushf 
        call dword ptr cs:[200h] 
 这里写成call dword ptr es:[200h]不对吗,为什么呀?
我自己编写成这样通不过,真的不知道为什么。
aukeys
[第10楼]   [ 回复时间:2008-11-28 17:56 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-11-08 21:55
call dword ptr cs:[200h] ;这里对吗?楼主测试了吗?
zyw23
[第11楼]   [ 回复时间:2008-12-15 14:06 ]   [引用]   [回复]   [ top ] 
荣誉值:2
信誉值:2
注册日期:2008-11-22 15:49
楼主只要把卸载程序中的指令,放到新int9中断中loop s指令后面就行了.
        mov ax, 0 
        mov ds, ax 

        cli 
        mov ax, ds:[200h] 
        mov ds:[9*4], ax 
        mov ax, ds:[202h] 
        mov ds:[9*4+2], ax 
        sti
leibniz007
[第12楼]   [ 回复时间:2008-12-16 01:03 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-11-11 10:05
我的代码跟你的几乎一样!!!
都是参照书上写的吧………………
suiyueran
[第13楼]   [ 回复时间:2009-02-01 16:54 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-01-31 16:41
俺是菜鸟一只,终于把实验15写好。现在将15章的例题也写了进来。因为俺不知道该怎么单独运行实验15.大家见笑了
assume cs:code
stack segment
  db 128 dup (0)
stack ends
code segment
start:mov ax,cs
        mov ds,ax
        mov si,offset int9
        mov ax,0
        mov es,ax
        mov di,204h
        mov cx,offset intend-offset int9
        cld
        rep movsb        
        
        push es:[9*4]
        pop es:[200h] ;这里把以前的int9地址保存
        push es:[9*4+2]
        pop es:[202h]
        cli
        mov word ptr es:[9*4],204h ;这里把新地址写入向量表
        mov word ptr es:[9*4+2],0
        sti
        
        mov ax,0b800h
        mov es,ax
        mov ah,'a'
ms:mov es:[160*12+80],ah
        call raa
        inc ah
        cmp ah,'z'
        jna ms
        
        mov ax,0
        mov es,ax
        cli
        push es:[200h]
        pop es:[9*4]
        push es:[202h]
        pop es:[9*4+2]
        sti
         
        mov ax,4c00h
        int 21h
        
raa:  push ax
        push dx
        mov dx,1000h
        mov ax,1
chong:sub ax,1
        sbb dx,0
        cmp ax,0
        jne chong
        cmp dx,0
        jne chong
        pop dx
        pop ax
        ret
int9:push ax
        push bx
        push cx
        push es
        
        in al,60h
        pushf
        call dword ptr cs:[200h]
        
        cmp al,9eh        
        jne int9ret
        mov ax,0b800h
        mov es,ax
        mov bx,0
        mov cx,4000        
s:    mov byte ptr es:[bx],'A'
        add bx,2        
        loop     s
int9ret:pop es
        pop cx
        pop bx
        pop ax
        iret 
intend:nop
        code ends
                end start
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved