目录

实验任务

编写、应用中断例程(课本实验13)

  1. 编写并安装int 7ch中断例程,功能为显示一个用0结束的字符串,中断例程安装在0:200处。

参数:(dh)=行号,(dl)=列号,(cl)=颜色,ds:si指向字符串首地址。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
assume cs:code
data segment
db 'welcome to masm!',0
data ends
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset dp
mov ax,0
mov es,ax
mov di,200h
mov cx,offset dpend-offset dp ;安装中断例程
cld
rep movsb
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 ;测试int 7ch
mov si,0
int 7ch
mov ax,4c00h
int 21h
dp:
mov al,160
mul dh
add dl,dl
mov dh,0
add ax,dx
mov di,ax
mov ax,0b800h
mov es,ax
;中断例程
s:
mov al,ds:[si]
mov ah,0
cmp ax,0
je f
mov ah,cl
mov es:[di],ax
inc si
inc di
inc di
jmp s
f:
iret
dpend:nop
code ends
end start


结果:

  1. 编写并安装int 7ch中断例程,功能为完成loop指令的功能。

参数:(cx)=循环次数,(bx)=位移

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset lp
mov ax,0
mov es,ax
mov di,200h
mov cx,offset lpend-offset lp ;安装中断例程
cld
rep movsb
mov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0 ;设置中断向量表

mov ax,0b800h
mov es,ax
mov di,160*12
mov bx,offset s-offset se
mov cx,80
s:
mov byte ptr es:[di],'!' ;测试int 7ch
add di,2
int 7ch
se:
nop
mov ax,4c00h
int 21h
lp:
push bp

dec cx
jcxz f
mov bp,sp
add [bp+2],bx ;中断例程
f:
pop bp
iret
lpend:nop
code ends
end start

结果:

  1. 下面的程序,分别在屏幕的第2、4、6、8行显示四句英文诗,补全程序。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

结果: