实验16
使用call指令直接调用标号不需要计算偏移量assume cs:code
code segment
start: movax,0
moves,ax
movdi,200H
movax,cs
movds,ax
movsi,offset setscreen
movcx,offset int7ch_end-offset setscreen
cld
repmovsb
movword ptr es:,200h
movword ptr es:,0h
movax,4c00h
int21h
; 功能: 调用指定的子程序
; 参数: (ah)=功能号(0-3)
; (al)=颜色值(0-7)
setscreen: cmpah,0
je do1
cmpah,1
je do2
cmpah,2
je do3
cmpah,3
je do4
jmpshort sret
do1: call sub1
jmpshort sret
do2: call sub2
jmpshort sret
do3: call sub3
jmpshort sret
do4: call sub4
sret: iret
; 清屏
sub1: push bx
push cx
push es
movbx,0b800h
moves,bx
movbx,0
movcx,2000
sub1s: movbyte ptr es:,' '
addbx,2
loop sub1s
popes
popcx
popbx
ret
; 设置前景色
sub2: push bx
push cx
push es
movbx,0b800h
moves,bx
movbx,1
movcx,2000
sub2s: andbyte ptr es:,11111000b ; 前景色置0
or es:,al ; 放入颜色值
addbx,2
loop sub2s
popes
popcx
popbx
ret
; 设置背景色
sub3: push bx
push cx
push es
movcl,4
shlal,cl
movbx,0b800h
moves,bx
movbx,1
movcx,2000
sub3s: andbyte ptr es:,10001111b ; 背景色置0
or es:,al ; 放入背景色值
addbx,2
loop sub3s
popes
popcx
popbx
ret
; 向上滚动一行
sub4: push cx
push si
push di
push es
push ds
movsi,0b800h
moves,si
movds,si
movsi,160 ; ds:si指向n+1行
movdi,0 ; es:di指向n行
cld
movcx,24
sub4s: push cx
movcx,160
repmovsb ; n+1行覆盖到n行上
popcx
loop sub4s
movcx,80
movsi,0
sub4s1: movbyte ptr ,' ' ; 最后一行清空
addsi,2
loop sub4s1
popds
popes
popdi
popsi
popcx
ret
int7ch_end:nop
code ends
end start
页:
[1]