您的位置:首页 > 其它

中断体验:观察自定义中断的安装及触发

2017-05-18 08:39 232 查看
【说明】中断机制是一种重要的解决问题的手段。针对初学者不能对中断的相关技术有直观的认识,特设计了这个学习活动。

【知识准备】中断向量表;中断处理过程;中断安装程序

【体验步骤】

步骤1 自定义78h号中断的中断处理例程,并将其安装到内存中

;文件名: ptest.asm
assume cs:code
code segment
start:mov ax,cs
mov ds,ax
mov ax,0
mov es,ax
;安装中断例程
lea si, do_78h
mov di,200h
mov cx,offset do78h_end - offset do_78h
cld
rep movsb
;设置中断向量表
mov word ptr es:[78h*4],200h
mov word ptr es:[78h*4+2],0
mov ax,4c00h
int 21h
;定义中断例程:显示"flying";
do_78h: jmp short istart
msg db 'flying!-Piao Guo....'
istart:
push ds
push es
push si
push di
push ax
push cx

mov ax, cs
mov ds, ax
mov si, 202h
mov ax,0b800h
mov es,ax
mov di,160*24
mov ah, 11001111b ;闪烁红底加亮白字
mov cx,offset istart - offset msg
s: mov al,[si]
mov es:[di],ax  ;字符与属性一起移入

inc si
add di,2
loop s
pop cx
pop ax
pop di
pop si
pop es
pop ds
iret
do78h_end:nop
code ends
end start


编译、连接及运行过程如下:



请说出来:运行以后什么也看到,程序的作用是什么?

步骤2 编程序,触发中断78h

;文件名: pa.asm
assume cs:code, ss:stack
stack segment stack
db  16 dup (0)
stack ends
code segment
start: int 78h
mov ax,4c00h
int 21h
code ends
end start


编译、连接、运行程序:



请说出:在运行pa时,发生了什么?为什么?

步骤3 在debug中载入pa.exe并单步运行,观察寄存器的变化

重点关注:CS、IP,以及标志寄存器中IF的值,如图,EI(允许)或DI(关闭)



一边观察,一边说出运行中涉及的中断的机制

步骤4 在debug中调用int 78h

按下面操作工作:



请说出,调用int 78时发生了什么?

步骤5:关闭DOSBOX,再打开,不做步骤1,直接从步骤2开始重做上面的工作。

请说出:你看到了什么?为什么会是这样?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  体验 内存 汇编