|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
写了个简单的程序想看下键盘中断的响应过程,这个程序一敲击键盘,就会重启。和以前写成功过的程序核对过,没有出入,自己查看也木有发现什么!没事儿的朋友,可以看看!权当复习知识了!
org 0x7c00
mov bx,cs
mov es,bx
mov bx,0x7e00
mov ax,0x0212
mov cx,2
mov dx,0
int 0x13
jmp 0:0x7e00
times 510 - ($-$$) db 0
dw 0xaa55
xor eax,eax
mov ax,cs
shl eax,4
add eax,LABEL_SEG_CODE32
mov [LABEL_DESC_CODE32 + 2],ax
shr eax,16
mov [LABEL_DESC_CODE32 + 4],al
mov [LABEL_DESC_CODE32 + 7],ah
xor eax,eax
mov ax,cs
shl eax,16
add eax,LABEL_GDT
mov [GdtPtr + 2],eax
xor eax,eax
mov ax,cs
shl eax,16
add eax,LABEL_IDT
mov [IdtPtr + 2],eax
cli
lgdt [GdtPtr]
lidt [IdtPtr]
in al,0x92
or al,2
out 0x92,al
mov eax,cr0
or al,1
mov cr0,eax
jmp dword SelectorCode32:0
[bits 32]
[section .text]
LABEL_SEG_CODE32:
mov ax,SelectorVideo
mov gs,ax
mov al,'P'
mov ah,0xc
mov [gs:0],ax
call Init8259A
sti
hlt
Init8259A:
mov al,0x11
out 0x20,al
call io_delay
out 0xa0,al
call io_delay
mov al,0x20
out 0x21,al
call io_delay
mov al,0x28
out 0xa1,al
call io_delay
mov al,4
out 0x21,al
call io_delay
mov al,2
out 0xa1,al
call io_delay
mov al,1
out 0x21,al
call io_delay
out 0xa1,al
call io_delay
mov al,1111_1101b
out 0x21,al
call io_delay
mov al,1111_1111b
out 0xa1,al
call io_delay
ret
io_delay:
nop
nop
nop
nop
ret
_handler:
handler equ _handler - $$
inc byte [gs:0]
in al,0x60
mov al,0x20
out 0x20,al
iretd
SegCode32Len equ $ - $$
LABEL_GDT dw 0,0,0,0
LABEL_DESC_CODE32 dw SegCode32Len - 1,0,0x9800,0x0040
LABEL_DESC_VIDEO dw 0xffff,0x8000,0x920b,0x0040
SelectorCode32 equ LABEL_DESC_CODE32 - LABEL_GDT
SelectorVideo equ LABEL_DESC_VIDEO - LABEL_GDT
GdtLen equ $ - LABEL_GDT
GdtPtr dw GdtLen - 1
dd 0
LABEL_IDT:
%rep 0x21
dw 0,0,0,0
%endrep
dw handler,SelectorCode32,0x8e00,0x00
IdtLen equ $ - LABEL_IDT
IdtPtr dw IdtLen - 1
dd 0
|
|