中断其实和调用子程序差不多,安装中断之前先把中断程序当作一个单独的子程序运行一下
下面是实验13,编写并安装int 7ch中断例程
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
程序代码:
assume cs:code
data segment
db "welcome to masm!",0
data ends
code segment
start:
mov dh,10
mov dl,10
mov cl,2
mov ax,data
mov ds,ax
mov si,0
call int7c
mov ah,0
int 16h
mov ax,4c00h
int 21h
;-----------------------------------
int7c:
push es
push bx
push cx
push ax
mov ax,0b800h
mov es,ax
mov al,dh
mov ah,160
mul ah
mov bx,ax
mov al,dl
mov ah,2
mul ah
add bx,ax
mov ch,0ffh
mov ah,cl
s:
mov al,[si]
cmp al,0
jz ok
mov es:[bx],al
mov es:[bx+1],ah
add bx,2
inc si
loop s
ok:
pop ax
pop bx
pop cx
pop es
ret
;--------------------------------------
code ends
end start
然后把子程序拿出来,放到安装中断程序的里面
程序代码:
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset int7c
mov ax,0
mov es,ax
mov di,200h
mov cx,offset int7cend-offset int7c
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[4*7ch],200h
mov word ptr es:[4*7ch+2],0
mov ax,4c00h
int 21h
;中断7ch,显示一个以0结束的字符串
;参数:(dh)=行号,(dl)=列号,(cl)=颜色,ds:si指向字符串首地址
int7c:
push es
push bx
push cx
push ax
mov ax,0b800h
mov es,ax
mov al,dh
mov ah,160
mul ah
mov bx,ax
mov al,dl
mov ah,2
mul ah
add bx,ax
mov ch,0ffh
mov ah,cl
s:
mov al,[si]
cmp al,0
jz ok
mov es:[bx],al
mov es:[bx+1],ah
add bx,2
inc si
loop s
ok:
pop ax
pop bx
pop cx
pop es
iret
int7cend:nop
code ends
end start
运行上面的程序,安装完成7ch中断例程后,执行下面的程序测试中断是否安装成功
程序代码:
data segment
db "welcome to masm!",0
data ends
code segment
start:
mov dh,10
mov dl,10
mov cl,2
mov ax,data
mov ds,ax
mov si,0
int 7ch
mov ah,0
int 16h
mov ax,4c00h
int 21h
code ends
end start
图片附件: 游客没有浏览图片的权限,请
登录 或
注册