. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  安装int9中断例程问题  [待解决] 回复[ 7次 ]   点击[ 644次 ]  
fenglixin70953
[帖 主]   [ 发表时间:2008-04-29 14:08 ]   [引用]   [回复]   [ top ] 
荣誉值:2
信誉值:0
注册日期:2008-01-23 09:03
assume cs:code
stack segment
db 128 dup(0)
stack ends
code segment
start:mov ax,stack
      mov ss,ax
      mov sp,128
      
      mov ax,cs
      mov ds,ax
      mov si,offset int9
      mov di,204h
      mov ax,0
      mov es,ax
      
      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,0b800h
      mov es,ax
      mov ah,'a'
   
    s3:
       mov cx,4000
       mov di,0
       cli
      
      s4: mov es:[di],ah
       mov byte ptr es:[di+1],2
       add di,2
       loop s4
       sti
       call delay
       inc ah
       cmp ah,'z'
       jna s3
       
       mov ax,0
       mov es,ax
       push es:[200h]
       pop es:[9*4]
       push es:[202h]
       pop es:[9*4+2]
     mov ax,4c00h
     int 21h
       
    
    
    delay:push ax
          push dx
          mov dx,1000h
          mov ax,0
        s5:sub ax,1
          sbb dx,0
          cmp ax,0
          jne s5
          cmp dx,0
          jne s5
          pop dx
          pop ax
          ret
    
      
      
      int9:push ax
           push bx
           push cx
           push es
           
           in al,60h
           pushf
          call dword ptr es:[200h]
           cmp al,1
           jne int9ret
           mov ax,0b800h
           mov es,ax
           mov bx,0
           mov cx,2000
         s:mov byte ptr es:[bx],41h
           mov byte ptr es:[bx+1],4
           add bx,2
           loop s
        
        
        int9ret:
            pop es
            pop cx
            pop bx
            pop ax
            iret
        int9end:nop
       
       
        code ends
        end start
     

程序按下esc键应该在屏幕上显示红色A,一直没成功,用debug调试到mov word ptr es:[9*4],204就死了。
程序运行时有时报错,按esc键和其它键反应一样的结果,请高手帮指点。我找了好长时间没发现问题。
younggay
[第1楼]   [ 回复时间:2008-04-29 16:12 ]   [引用]   [回复]   [ top ] 
荣誉值:273
信誉值:0
注册日期:2008-01-23 20:23
这个程序是在满屏的循环显示字母么?!
fenglixin70953
[第2楼]   [ 回复时间:2008-04-29 16:14 ]   [引用]   [回复]   [ top ] 
荣誉值:2
信誉值:0
注册日期:2008-01-23 09:03
满屏显示,终于找到哪错了,进入int9字程序call word ptr es:[200h]这应是cs。
younggay
[第3楼]   [ 回复时间:2008-04-29 16:18 ]   [引用]   [回复]   [ top ] 
荣誉值:273
信誉值:0
注册日期:2008-01-23 20:23
楼主先把其他的功能都去掉,就实现一个按间在屏幕上显示满屏红A的中断。讲问题具体化,范围缩小化,一点一点的攻陷吧。
不要用debug在设置中断向量的时候中断,否则你的int 9本来就是键盘中断,而你在设置变量的时候产生了按键,此时你修改了变量的段地址,而偏移地址还没有修改好就产量了按键,调用的中断例程就错了,所以,就会出现错误了。
younggay
[第4楼]   [ 回复时间:2008-04-29 16:19 ]   [引用]   [回复]   [ top ] 
荣誉值:273
信誉值:0
注册日期:2008-01-23 20:23
cli 
      mov word ptr es:[9*4],204h 
      mov word ptr es:[9*4+2],0 
       
      sti 

----------------
debug下,设置中断向量的时候,不要出现中断,一次运行完毕,用g命令。
gxyfct18
[第5楼]   [ 回复时间:2011-07-21 09:35 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-07-05 15:50
非常感谢younggay!
miaoasm
[第6楼]   [ 回复时间:2011-07-24 14:51 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-06-13 15:40
cli 
      mov word ptr es:[9*4],204h 
      mov word ptr es:[9*4+2],0 
       
      sti 

----------------
debug下,设置中断向量的时候,不要出现中断,一次运行完毕,用g命令。
------------------
回复:
linguangliang
[第7楼]   [ 回复时间:2011-10-06 14:57 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-10-05 20:01
自写的int9中断例程为什么一定要调用原来的int 9处理一些硬件细节?? ,由于60h中保存的就是按键扫描码,我们可不可以直接不调用原来的int 9中断就进行判断来决定是否如何改变字符颜色??
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved