您的位置:首页 > 其它

王爽 汇编 实验16 编写包含多个功能子程序的中断例程

2015-11-06 22:55 495 查看
assume cs:code

code segment
start:
mov ax,cs
mov ds,ax
mov si,offset setscreen
mov ax,0
mov es,ax
mov di,0200h
mov cx,offset endsetscreen-offset setscreen
rep movsb

mov ax,0
mov es,ax
mov word ptr es:[7ch*4],0200h
mov word ptr es:[7ch*4+2],0000h

mov ax,4c00h
int 21h

setscreen:

jmp short set
table dw clear-setscreen+200h,foreground-setscreen+200h,background-setscreen+200h,rollup-setscreen+200h;
set:
push bx
cmp ah,0
jb sret
cmp ah,3
ja sret
mov bl,ah
mov bh,0
add bx,bx
call word ptr cs:[table+bx-setscreen+200h]

sret:
pop bx
iret

clear:
push bx
push cx
push es
push si

mov bx,0b800h
mov es,bx
mov si,0
mov cx,2000

loopclear:
mov byte ptr es:[si],' '
add si,2
loop loopclear

pop si
pop es
pop cx
pop bx
ret

foreground:
push bx
push cx
push es
push si

mov bx,0b800h
mov es,bx
mov si,1
mov cx,2000

loopforeground:
and byte ptr es:[si],11111000b
or es:[si],al
add si,2
loop loopforeground

pop si
pop es
pop cx
pop bx
ret

background:
push bx
push cx
push es
push si

mov bx,0b800h
mov es,bx
mov si,1
mov cx,2000
shl al,1
shl al,1
shl al,1
shl al,1

loopbackground:
and byte ptr es:[si],10001111b
or es:[si],al
add si,2
loop loopbackground

pop si
pop es
pop cx
pop bx
ret

rollup:
push bx
push cx
push ds
push es
push si
push di

mov bx,0b800h
mov ds,bx
mov es,bx
mov cx,24
mov si,160
mov di,0
cld
looprollup:
push cx
mov cx,160
rep movsb
pop cx
loop looprollup

mov cx,80
mov si,0
clearlast:
mov byte ptr es:[160*24+si],' '
add si,2
loop clearlast

pop di
pop si
pop es
pop ds
pop cx
pop bx
ret

endsetscreen:
nop

code ends
end start
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: