;安装一个新的int7ch终端例程,为显示输出提供如下功能子程序;入口参数:;ah传递功能号;al传递颜色值
assume cs:code
code segment
start:mov bx,cs
mov ds,bx
mov si,offset int7ch
mov bx,0mov es,bx
mov di,200h
mov cx,offset int7ch_end-offset int7ch
cld
rep movsb
climov word ptr es:[7ch*4],200h
mov word ptr es:[7ch*4+2],0
sti
mov ah,2mov al,2
int 7ch
mov ax,4c00h
int 21h
ORG 200H
;中断例程int7ch:push ax
push bx
jmp begin
table dw sub0,sub1,sub2,sub3
begin:
cmp ah,3
ja sret
add bl,ah
mov bh,0add bx,bx
call word ptr table[bx]
sret:pop ax
pop bx
iret
;清屏sub0:push bx
push es
push ds
push di
push si
push cx
mov bx,0b800h
mov es,bx
mov ds,bx
mov si,160mov di,0mov cx,24
cld
sub0s:push cx
mov cx,160
movsb
mov cx,80mov si,0pop cx ;
loop sub0s ;sub0ss:mov word ptr es:[si][160*24],' 'add si,2
loop sub0ss
pop cx
pop si
pop di
pop ds
pop es
pop bx
ret;改变前景色sub1:push ax
push bx
push es
push cx
push di
mov bx,0b800h
mov es,bx
mov di,1mov cx,2000sub1s:and byte ptr es:[di],11111000b
or es:[di],al
add di,2
loop sub1s
pop di
pop cx
pop es
pop bx
pop ax
ret;改变背景色 sub2:push bx
push es
push cx
mov cl,4;al的取值范围是0-7,只占前4个字节
shl al,cl ;但是背景色是第4-6位,所以无法重合,需要左移4位mov bx,0b800h
mov es,bx
mov bx,1mov cx,2000sub2s:and byte ptr es:[bx],10001111b
or es:[bx],al
add bx,2
loop sub2s
pop cx
pop es
pop bx
ret;向上滚动一行sub3:push bx
push es
push ds
push di
push si
push cx
mov bx,0b800h
mov es,bx
mov ds,bx
mov di,0mov si,160
cld
mov cx,24sub3s:push cx
mov di,0mov si,160mov cx,160
rep movsb
pop cx
loop sub3s
sub3ss:mov byte ptr [160*24+si],' ';add si,2
loop sub3ss;最后一行清空pop cx
pop si
pop di
pop ds
pop es
pop bx
retint7ch_end:nop
code ends
end start