改写中断例程小实验

1.安装一个新的int9中断例程

2.在DOS下,按f1改变屏幕颜色,其它键不变

assume cs:code,ss:stk

stk segment
	db 128 dup (0)
stk ends

code segment
start:
	mov ax,stk
	mov ss,ax
	mov sp,128
	mov ax,0
	mov es,ax
	push cs
	pop ds
	
	;将原中断保存至0:200h
	push es:[4*9]
	pop es:[200h]
	push es:[4*9+2]
	pop es:[202h]
	
	;安装新程序
	mov si,offset int9
	mov di,204h
	mov cx,offset int9end - offset int9
	cld
	rep movsb
	
	;改变后中断的入口地址
	cli
	mov word ptr es:[9*4],204h
	mov word ptr es:[9*4+2],0
	sti
	
	mov ax,4c00h
	int 21h
;自定义int9中断
int9:
	push ax
	push bx 
	push cx
	push es
	
	in al,60h
	pushf
	call dword ptr cs:[200];此时cs为0
	;处理f1
	cmp al,3bh ;f1扫描码为3bh
	jne int9ret
	mov ax,0b800h
	mov es,ax
	mov bx,1
	mov cx,2000
	s:inc byte ptr es:[bx]
	  add bx,2
	  loop s
int9ret:
	pop es
	pop cx
	pop bx
	pop ax
	iret
int9end:nop
code ends
end start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值