键盘中断

;中断类型码一共有256个(一个字节)
;中断向量表在内存的地址为0开始到1023单元
;每个类型码的cs和ip分别占2个字节,因为一个物理地址是32位,这跟
;物理地址=cs*16+ip是一样的的 




;步骤:
;1:获得源入口地址(类型码*4,类型码*4+2),因为最后要把int9恢复
;2:




;按esc键改变颜色
assume cs:code 


stack segment 
db 128 dup(0)
stack ends 


data segment 
dw 0,0 
data ends 
code segment 
start: 
mov ax,stack ;;
mov ss,ax ;stack location
mov sp,128

mov ax,data  ;enter address
  mov ds ,ax

mov ax,0
mov es ,ax 

push es:[9*4]
pop ds:[0] ;old enter address's IP
push es:[9*4+2] ;old enter addess's CS
pop ds:[2]

mov word ptr es:[9*4], offset int9;set new enter address's IP 
mov es:[9*4+2],cs;set  new enter address's CS

mov ax,0b800h
mov es,ax
mov ah,'a'

s:
mov es:[160*12 + 40*2 ],ah
call delay 
inc ah 
cmp ah,'z'
jna s
;
;Restore source int9 entry address
mov ax ,0 
mov es,ax 
push ds:[0]
pop es:[9*4]
push ds:[2]
pop es:[9*4+2]

mov ax,4c00h
int 21h

delay :
push ax
push dx

mov dx,1000h
mov ax,0

s1:
sub ax,1
sbb bx,0
cmp ax,0
jne s1
cmp dx,0
jne s1
pop dx
pop ax
ret 

;;;;;;;;;;;;;;
;new  interrupt content 


int9:
push ax
push bx
push es 
in al,60h

pushf   ;old flag bit  
pushf ;new flag bit
pop bx 
and bh ,11111100b ;change new flag bit 
push bx
popf 
call dword ptr ds:[0]
cmp al,1
jne int9ret

mov ax,0b800h
mov es,ax
inc byte ptr es:[160*12+40*2+1]

int9ret :
pop es
pop bx
pop ax 
iret 
code ends 
end start 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值