编译并安装int 7ch中断例程,功能为显示一个用0结束的字符串,中断例程安装在0:200
assume cs:code
assume cs:code
code segment
start: mov ax,cs
mov ds,ax
mov si,offset show
mov ax,0
mov es,ax
mov di,200h
mov cx,offset showend - offset show
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,4c00h
int 21h
show: push dx
push cx
push si
mov di,0
;dec dh ; 此处是个坑!
mov ah,0
mov al,160
mul dh
mov di,ax
dec dl
mov ah,0
mov al,2
mul dl
add di,ax
mov ax,0b800h
mov es,ax ;指定显示缓存区的内存位置
mov al,cl ; 由于后面jcxz语句的判断要用到cx,所以我们要将
; cl(颜色)先存下来。
next: mov cl,ds:[si]
mov ch,0
jcxz ok
mov es:[di],cl ;存字符
mov es:[di+1],al ;存颜色
inc si
add di,2
jmp short next
ok: pop si
pop cx
pop dx
iret
showend:nop
code ends
end start
编译并安装int 7ch中断例程,功能为完成loop指令的功能
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 ax,0
mov es,ax
mov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0
mov ax,4c00h
int 21h
lp: push bp
mov bp,sp
dec cx
jcxz lpret
add [bp+2],bx ; bx为从标号 se 到标号 s 转移位移
lpret: pop bp
iret
lpend: nop
code ends
end start
下面的程序,分别在第2、4、6、8行显示4句英文诗,补全程序。
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 ;第0页
mov dh,ds:[si] ;行号
mov dl,0 ;列号
mov ah,2 ;置光标
int 10h
mov dx,ds:[bx] ;ds:dx 指向字符串的首地址
mov ah,9 ;ah=9 调用21h中断例程的9号子程序,
int 21h ;功能是在光标位置显示字符串
inc si
add bx,2
loop ok
mov ax,4c00h
int 21h
code ends
end start