鱼C论坛

 找回密码
 立即注册
查看: 1549|回复: 1

汇编实验15不能设置中断入口地址

[复制链接]
发表于 2013-3-18 10:50:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
assume cs:code, ss:stack

stack segment
      db 128 dup(0)
stack ends

code segment

start:    call init                                             
          call display

          mov ax,4c00h
                  int 21h
                  
display:  push ax
          push es
          mov ax,0b800h                  
                  mov es,ax
                  mov ah,'a'
s0:                  mov es:[160*12+40*2],ah
                  call delay
                  inc ah       
                  cmp ah,'z'
                  jna s0
return:          pop es
                  pop ax
                  ret                  

delay:    push ax
          push bx         
                 mov bx,1000h
          mov ax,0
s1:       sub ax,1
          sbb bx,0
          cmp ax,0
          jne s1
          cmp bx,0
          jne s1
          pop bx
          pop ax
          ret       

init:     mov ax,stack     ;起初设置栈段地址
          mov ss,ax
                  mov sp,128       ;设置栈顶指针
                  
                  mov ax,0         ;设置目标地址的段地址
                  mov es,ax
                  mov di,0204h     ;设置目的偏移地址
                  
                  push cs          ;设置源操作数段地址
                  pop ds
                  mov si,offset int9
                  
                  mov cx,offset endint9 - offset int9
                  cld             ;设置偏移地址往前递增DF=0
          rep movsb
                  
                  push es:[9*4]   ;将中断向量标中的地址存放在200h和202h四个字节中
                  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                      ;开中断允许位
                  
          ret                                      
                  
int9:     push ax
          push es

          pushf          ;进入中断9以后已经将IF和TF置0了                  
          in al,60h
                  call dword ptr cs:[200h]
                  
                  cmp al,1
                  jne s3
                  mov ax,0b800h
                  mov es,ax
                  inc byte ptr es:[160*12+40*2+1]
                            
s3:       pop es
          pop ax
          iret
endint9:  nop                  

code ends

end start

总是在mov word ptr es:[9*4],204H被系统提出来是怎么回事啊!我搞了好久了啊!

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2013-4-11 14:20:02 | 显示全部楼层
我也是一样的问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-7 20:28

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表