8259A Need help 2
Posted: Mon Nov 20, 2006 8:08 pm
Hello, all!
After a long discussion I wrote the simpliest code to initialize PICs. Certainly it fails, and I don't know why...
The code just set up interrupt handler, initialize PICs, disables all interrupts except from a keyboard and waits in 'jmp $'. The code is loaded at 0x1000:0x0.
System just hangs, without any reaction on keypresses. The same behavior in Bochs (tried to run it with 'show int' option). What's wrong?..
TIA, Mikae.
After a long discussion I wrote the simpliest code to initialize PICs. Certainly it fails, and I don't know why...
The code just set up interrupt handler, initialize PICs, disables all interrupts except from a keyboard and waits in 'jmp $'. The code is loaded at 0x1000:0x0.
Code: Select all
ICW1 = 0x11 ;NO LTIM, NO ADI, NO SNGL, ICW4.
ICW2_MASTER = 0x8 ;Interrupt vectors base.
ICW2_SLAVE = 0x10 ;Interrupt vectors base.
ICW3_MASTER = 0x4 ;IRs, where children are connected
ICW3_SLAVE = 0x2 ;Child's ID? Not sure about this number...
ICW4_MASTER = 0x1 ;NO SFNM, NOT BUFFER, 8086.
ICW4_SLAVE = 0x1 ;NO SFNM, NOT BUFFER, 8086.
mov ax, 0x1000
mov ds, ax
mov fs, ax
mov gs, ax
xor ax, ax
mov es, ax
mov cx, HNDLR_SIZE ;copy handler to its place.
mov si, hndlr
mov di, 0x600
rep movsb
;Init PICs
cli
mov al, ICW1
out 0x20, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW2_MASTER
out 21h, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW3_MASTER
out 0x21, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW4_MASTER
out 0x21, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW1
out 0xA0, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW2_SLAVE
out 0xA1, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW3_SLAVE
out 0xA1, al
jmp short $ + 2
jmp short $ + 2
mov al, ICW4_SLAVE
out 0xA1, al
jmp short $ + 2
jmp short $ + 2
;Mask all interrupts, except 0x1
mov al, 0xFD
out 0x21, al
jmp short $ + 2
jmp short $ + 2
mov word [0x24], 0x600 ;installing handler to IVT.
mov word [0x26], 0
sti
jmp $
hndlr:
mov ax, 0xB800
mov ds, ax
xor ax, ax
mov es, ax
mov al, 'B'
mov ah, 0xF
mov bx, [es:cur_pos]
mov [bx], ax
add word [es:cur_pos], 0x2
iret
cur_pos: dw 0x0
HNDLR_SIZE = $ - hndlr
TIA, Mikae.