实验16
assume cs:codecode segment
start:
mov ax,cs
mov ds,ax
mov si,offset do0
mov ax,0
mov es,ax
mov di,200h ;将do0写到0:200处
mov cx,offset do0end-offset do0
cld
rep movsb
;设置中断向量表
mov ax,0
mov es,ax ;将es指向中断向量表
mov word ptr es:,200h ;发生7ch中断时跳转到0:200处执行
mov word ptr es:,0
mov ax,4c00h
int 21h
;(1)清屏
;(2)设置前景色
;(3)设置背景色
;(4)向上滚动一行
;参数:
;ah:功能号,0清屏,1设置前景色,2设置背景色,3向上滚动一行
;针对1,2号功能,用al传递颜色值,0<=al<=7
do0: jmp short set
table: dw 200h+offset sub1-offset do0,200h+offset sub2-offset do0,200h+offset sub3-offset do0,200h+offset sub4-offset do0
set:
cmp ah,3
ja sret
push es
push si
push ax
push cx
push bx
push di
mov cx,0B800H
mov es,cx
mov si,0
add ah,ah ;word两字节,ah*2
mov cx,0
mov cl,ah
mov bx,200h+offset table-offset do0
add bx,cx
call word ptr cs: ;调用对应的功能子程序
pop di
pop bx
pop cx
pop ax
pop si
pop es
sret: iret
sub1:
mov ax,0020H ;' '
mov cx,80*25 ;每页80*25个字符
s0: mov es:,ax
add si,2
loop s0
ret
sub2:
mov cx,80*25 ;每页80*25个字符
cmp al,1
jb rsub2
cmp al,7
ja rsub2
s1:
mov bh,es:
and bh,11111000b ;前景色清零
or bh,al
mov es:,bh
add si,2
loop s1
rsub2: ret
sub3:
mov cx,80*25 ;每页80*25个字符
cmp al,1
jb rsub3
cmp al,7
ja rsub3
shl al,1
shl al,1
shl al,1
shl al,1
s2:
mov bh,es:
and bh,10001111b ;被景色清零
or bh,al
mov es:,bh
add si,2
loop s2
rsub3: ret
sub4:
mov cx,80*24
mov di,160
s3:
mov ax,es:
mov es:,ax
add si,2
add di,2
loop s3
mov cx,80 ;清空最后一行
mov bh,20H
s4: mov es:,bh
add si,2
loop s4
ret
do0end: nop
code ends
end start
心情不太好,感觉有点乱糟糟的,懒得改了{:10_262:} 测试程序
assume cs:code
code segment
start:
;设置前景色为2ok
mov al,2
mov ah,1
int 7ch
call delay
;设置背景色 4
mov al,4
mov ah,2
int 7ch
call delay
;向上滚动一行
mov ah,3
int 7ch
call delay
;清屏
mov ah,0
int 7ch
call delay
mov ax,4c00h
int 21h
delay: push ax
push dx
mov dx,10h
mov ax,0
s1: sub ax,1
sbb dx,0
jne s1
cmp dx,0
jne s1
pop dx
pop ax
ret
code ends
end start
页:
[1]