王爽 汇编 实验16 增加键盘中断调用int 7ch中断例程

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
;int 7ch中断例程及安装保持不变

assume cs:code

code segment
start:
	mov ax,cs
	mov ds,ax
	mov si,offset int9start

	mov ax,0
	mov es,ax
	mov di,0304h

	mov cx, offset int9end-offset int9
	rep movsb

	mov ax,es:[9*4]
	mov dx,es:[9*4+2]
	mov es:[0300h],ax
	mov es:[0302h],dx
	mov word ptr es:[9*4],0304h
	mov word ptr es:[9*4+2],0000h

	mov ax,4c00h
	int 21h

int9:
	jmp short int9start
	int9start:
	push ax
	push es
	mov ax,0
	mov es,ax
	pushf
	call dword ptr es:[0300h]

	in al,60h
	cmp al,0bh
	jne s1
	mov ah,0
	mov al,02h
	jmp short s2
	s1:
	cmp al,02h
	jb ok
	cmp al,04h
	ja ok
	sub al,1
	mov ah,al
	mov al,02h

	s2:
	int 7ch

	ok:
	pop es
	pop ax
	iret
	int9end:
	nop

	



code ends
end start

;新增int 9键盘中断例程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值