需求
安装一个新的 int 7ch
中断例程,为显示输出提供如下功能子程序。
功能 | 1. 清屏; 2. 设置前景色; 3. 设置背景色; 4. 向上滚动一行。 |
---|---|
参数 ah |
用 ah 寄存器传递功能号 : 0 表示清屏,1 表示设置前景色,2 表示设置背景色, 3 表示向上滚动一行; |
参数 al |
用 al 传送颜色值 ,(al) ∈ { 0,1,2,3,4,5,6,7 } 。用于 1 、2 号功能 |
s16.asm
assume cs:code
code segment
start:
call install_int7ch
mov ah,0
mov al,3
int 7ch
mov ax,4c00h
int 21h
; =======================================================
; ------------------- 子程序 install_7ch -----------------
; 设置显示效果
; -------------------------------------------------------
; 参数: 无
; 返回: 无
; -------------------------------------------------------
install_int7ch:
push ax
push si
push di
push es
push cx
; ---------------- 安装(复制数据) ----------------
mov ax,cs
mov ds,ax
mov ax,0
mov es,ax
mov si,offset int7ch ;设置 ds:si 指向源地址
mov di,200h ;设置 es:di 指向目的地址
mov cx,offset int7ch_end-offset int7ch
cld ;设置传输方向为正。movsb中si,di递增
rep movsb ;将ds:si 拷贝到 es:di 长度cx
; ---------------- 安装(复制数据) ----------------
; ----------------- 设置中断向量 -----------------
mov ax,0
mov es,ax
cli ; 临时屏蔽中断
mov word ptr es:[7ch*4],200h ; 设置【中断处理程序】的:偏移地址
mov word ptr es:[7ch*4+2],0h ; 设置【中断处理程序】的:段地址
sti ; 恢复中断响应
; ----------------- 设置中断向量 -----------------
pop cx
pop es
pop di
pop si
pop ax
ret
; -------------------- 子程序 install_7ch -----------------
; =================================================