汇编语言实验13编写、应用中断例程

(1)编写并安装int 7ch中断例程,功能为显示一个用0结束的字符串,中断例程安装在0:200处。
参数:(dh)=行号,(dl)一列号,(c1)二颜色,ds:si指向字符串首地址。
以上中断例程安装成功后,对下面的程序进行单步跟踪,尤其注意观察int, fret指令执行前后CS, IP和栈中的状态。

assume cs:code

data segment
 db 'welcome to masm! ',0
data ends

code segment
start:
    mov ax,cs
    mov ds,ax
    mov si,offset capital
    mov ax,0
    mov es,ax
    mov di,200h
    mov cx,offset capitalend-offset capital
    cld
    rep movsb

    mov ax,0
    mov es,ax
    mov word ptr es:[7ch*4],200h
    mov word ptr es:[7ch*4+2],0

    mov dh,10
    mov dl,    10
    mov cl,2
    mov ax,data
    mov ds,ax
    mov si,0
    int 7ch

    
    mov ax,4c00h
    int 21h

capital:
    push ax
    push es
    push di
    push si

    mov ax,0b800h
    mov es,ax

    mov al,0a0h
    mul dh
    mov di,ax

    mov al,2
    mul dl
    add di,ax

    mov ah,cl
s:
    mov al,[si]
    cmp al,0
    je ok

    mov word ptr es:[di],ax
    add di,2
    inc si
    jmp short s
ok:
    pop si
    pop di
    pop es
    pop ax
    iret

capitalend:
    nop

code ends
end start

(2)编写并安装int 7ch中断例程,功能为完成loop指令的功能。
参数:(cx)=循环次数,(bx)一位移。
以上中断例程安装成功后,对下面的程序进行单步跟踪,尤其注意观察int, iret指令执行前后CS, IP和栈中的状态。
在屏幕中问显示80个“!”

assume cs:code
code segment
start:
    mov ax,cs
    mov ds,ax
    mov si,offset capital

    mov ax,0
    mov es,ax
    mov di,200h
    mov cx,offset capitalend-offset capital
    cld
    rep movsb

    mov ax,0
    mov es,ax
    mov word ptr es:[7ch*4],200h
    mov word ptr es:[7ch*4+2],0


    mov ax,0b800h
    mov es,ax
    mov di,12*160
    mov bx,offset s-offset se
    mov cx,80


s:
    mov byte ptr es:[di],'!'
    add di,2
    int 7ch
se:
    nop
    mov ax,4c00h
    int 21h


capital:
    push bp
    mov bp,sp
    dec cx
    jcxz ok
    add [bp+2],bx
ok:
    pop bp
    iret
capitalend:
    nop
code ends
end start

发布日期:

所属分类: 易语言 标签: