王爽 汇编语言 实验12

时间:2021-04-24 19:24:00

主要思路:  1.将中断的处理程序以数据方式写入到内存中.(显示overflow字符串.)

      2.修改中断向量表的值,使0号表项指向中断处理程序的开始地址

        3.开始除法运算,引发除法溢出错误.     

 1 assume cs:codeseg
 2 
 3 data segment
 4     db 16 dup (0)
 5 data ends
 6 codeseg segment
 7     start:
 8         ;do0程序的安装,将do0程序写入到内存0:200处
 9         mov ax,cs
10         mov ds,ax
11         mov si,offset do0    
12         mov ax,0
13         mov es,ax
14         mov di,200h
15         mov cx,offset do0end-offset do0    ;算出cx要循环的长度
16         cld            ;正向
17         rep movsb
18         
19         ;将do0的入口地址送入中断向量表0号表中.
20         mov ax,0
21         mov es,ax
22         mov word ptr es:[4*0],200h    ;低地址存放偏移地址
23         mov word ptr es:[4*0+2],0    ;高地址存放段地址
24                                     
25         mov ax,1000h    ;进行除法运算,引发除法溢出错误.
26         mov bh,1
27         div bh
28         
29         mov ax,4c00h
30         int 21h
31             
32         ;显示字符串
33         do0:jmp short do0start
34             db "overflow tri"
35         do0start:
36             mov ax,cs
37             mov ds,ax
38             mov si,202h
39             
40             mov ax,0b800h
41             mov es,ax
42             mov di,12*160+36*2
43             
44             mov bl,42h
45             mov cx,12        ;共12个字符
46         s:    mov al,[si]
47             mov es:[di],al        
48             mov es:[di+1],bl    ;设置字符颜色为红底绿字
49             inc si
50             add di,2            ;一个字符占两字节.低位ASCII码.高位字符属性
51             loop s
52         
53             mov ax,4c00h
54             int 21h
55         do0end:nop        
56         
57 codeseg ends
58 
59 end start