"Assembly Language" Third Edition Wang Shuang Experiment 12

Exercise 12 Write the processing program
for interrupt 0. Write the processing program for interrupt 0 so that when the division overflow occurs, the string "divide error!" is displayed in the middle of the screen, and then returns to DOS

 assume cs:codesg
 codesg segment
     ;安装中断程序
 start:    
     mov ax,cs
     mov ds,ax
     mov si,offset sub

     mov ax,0
     mov es,ax
     mov di,200H
     
     mov cx,offset sub-offset subend
     cld
     rep movsb

     ;设置中断向量表
     mov ax,0
     mov es,ax
     mov word ptr es:[0*4],200H
     mov word ptr es:[0*4+2],0

     mov ax,4c00H
     int 21H

     ;设置中断程序
sub: jmp s
     db "divide error!"

  s: mov ax,cs
     mov ds,ax
     mov si,offset sub+2
  
     mov ax,0b800H
     mov es,ax
     mov di,12*160+36*2
     
     mov cx,13
 s0: mov al,ds:[si]
     mov es:[di],al
     inc si
     add di,2
     loop s
     
     mov ax,4c00H
     int 21H
codese ends
end start

Guess you like

Origin blog.csdn.net/Xgggcalled/article/details/113745930