编程任务:
编写0号中断处理程序,使得在除法溢出发生时,在屏幕中间显示字符串“devide error!”,然后返回到DOS。
assume cs:code code segment start: ;1.安装程序 mov ax,cs mov ds,ax mov si,offset interrupt ;ds:si point to source address mov ax,0 mov es,ax mov di,200h ;es,di point to destination address mov cx,offset interend - offset interrupt ;set length of interrupt program code cld rep movsb ;2.设置中断向量表 mov ax,0 mov ds,ax ;ds指向段地址为0000 mov ax,20dh mov [0],ax ;把偏移地址在20d赋值给ds:0,它代表中断程序的偏移地址 mov ax,0 mov [2],ax ;把偏移地址0赋值给ds:2,它代表中断程序的段地址 ;3. 返回DOS mov ax,4c00h int 21h ;4.中断程序 interrupt: db "devide error!" show_str: mov ax,0 mov ds,ax mov bx,200h ;ds:bx指向要显示的字符串首地址,注:此字符串存放在0000:0200 mov ax,0b800h mov es,ax mov di,12*160+36*2 ;es:di指向字符串要显示的位置:屏幕中央 mov cx,13 display: mov al,[bx] mov es:[di],al inc bx add di,2 loop display ;通过循环实现 mov ax,4c00h int 21h interend: nop code ends end start