编写并安装int 7ch中断例程,功能为显示一个用0结束的字符串,中断例程安装在0:200处。
参数:(dh)=行号,(dl)=列号,(cl)=颜色,ds:si指向字符串首地址。
以上中断例程安装成功后,对下面的程序进行单步跟踪,尤其注意观察int 、iret指令执行后CS、IP和栈中的状态。
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
int 7ch
mov ax,4c00h
int 21h
code ends
end start
编写并安装int 7ch中断例程,功能为完成loop指令的功能。
参数:(cx)=循环次数,(bx)=位移
以上中断例程安装成功后,对下面的程序进行单步跟踪,尤其注意观察int 、iret指令执行前后CS、IP和栈中的状态。
在屏幕中间显示80个‘!’
assume cs:code
code segment
start: mov ax,0b800h
mov es,ax
mov di,160*12
mov bx,offset s-offset se ;设置从标号se到标号s的转移位移
mov cx,80
s: mov byte ptr es:[di],'!'
add di,2
int 7ch ;如果(cx)!=0,转移到标号s处
se: nop
mov ax,4c00h
int 21h
code ends
end start
下面的程序,分别在屏幕的第2、4、6、8行显示四句英文诗,补全程序。
assume cs:code
coe segment
s1: db 'Good,btter,best,','$'
s2: db 'Never let it rest,','$'
s3: db 'Till good is better,','$'
s4: db 'And better,best.','$'
s : dw offset s1,offset s2,offset s3,offset s4
row:db 2,4,6,8
start: mov ax,cs
mov ds,ax
mov bx,offset s
mov si,offset row
mov cx,4
ok: mov bh,0
mov dh,________
mov dl,0
mov ah,2
int 10h
mov dx,________
mov ah,9
int 21h
_____________
_____________
loop ok
mov ax,4c00h
int 21h
code ends
end start
完成后编译运行,体会其中的编程思想。
上代码 t1:
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset show_str
mov ax,0000h
mov es,ax
mov di,200h
mov cx,offset show_strend - offset show_str
cld
rep movsb
mov ax,0000h
mov es,ax
mov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0000h
mov ax,4c00h
int 21h
show_str:
push dx
push cx
push si
mov ax,0b800h
mov es,ax
mov ax,0
mov al,160
mul dh
mov bx,ax
mov ax,0
mov al,2
mul dl
add bx,ax
mov di,0
mov al,cl
mov ch,0
show:
mov cl,ds:[si]
jcxz ok
mov es:[bx+di+0],cl
mov es:[bx+di+1],al
add di,2
inc si
jmp short show
ok:
pop si
pop cx
pop dx
iret
show_strend:
nop
code ends
end start
t2:
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset lp
mov ax,0000h
mov es,ax
mov di,200h
mov cx,offset lpend - offset lp
cld
rep movsb
mov ax,0000h
mov es,ax
mov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0000h
mov ax,4c00h
int 21h
lp:
push bp
mov bp,sp
dec cx
jcxz lpret
add [bp+2],bx
lpret:
pop bp
iret
lpend:
nop
code ends
end start
t3:
assume cs:code
code segment
s1: db 'Good,better,best,','$'
s2: db 'Never let it rest,','$'
s3: db 'Till good is better,','$'
s4: db 'And better,best.','$'
s: dw offset s1,offset s2,offset s3,offset s4
row: db 2,4,6,8
start:
mov ax,cs
mov ds,ax
mov bx,offset s
mov si,offset row
mov cx,4
ok:
mov bh,0
mov dh,[si]
mov dl,0
mov ah,2
int 10h
mov dx,[bx]
mov ah,9
int 21h
inc si
add bx,2
loop ok
mov ax,4c00h
int 21h
code ends
end start