interrupts

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
LOneWoolF

interrupts

Post by LOneWoolF »

I'm not the biggest assambl-progger, most of my code will be in c

but there's one thing i don't know

when i create my [tt]INTX[/tt] interrupt proc in assambly, how can i tell the system that this is the interrupt function for interrupt X?

i saw following on a page i don't know now...
[tt]
mov es:[16h], offset MyInt16
[/tt]

but i get error: comma or end line expected...
(i use NASM)

GreeZ
LOneWoolF
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:interrupts

Post by Pype.Clicker »

if you are in real mode, you can redefine your interrupt handler by just writing a far pointer in the Interrupt Vector Table. For interrupt X, that far pointer is located at 0000:X*4

note that both the offset and the segment of the code must be added there.

If you're in protected mode, what you have to do is define the right descriptor in your IDT (but i suggest you read the Intel manual about Interrupts before you attempt this)
blip

Re:interrupts

Post by blip »

mov es:[16h], offset MyInt16

The correct form for that particular instruction wouldn't use OFFSET, as NASM doesn't need it. Also, you need to specify the data size, e.g.:
MOV ES:[16h],WORD MyInt16

If I'm right that you're trying to setup INT 16h's vector in realmode, use this code:
xor bp,bp
mov ax,MyInt16h
mov es,bp
cli
stosw
mov es:[16h * 4 + 2],seg MyInt16h
sti
LOneWoolF

Re:interrupts

Post by LOneWoolF »

but i'm in pmode :'(

now i need to set up real mode and use the code u gave me
thx
GreeZ
LOneWoolF
Slasher

Re:interrupts

Post by Slasher »

you need to set up an Interrupt Description Table. Have you read the Intel docs? If not, you should.
LOneWoolF

Re:interrupts

Post by LOneWoolF »

some questions:

where can i find the intel docs?
i also would like some more docs about idts
i bet there is an interrupt for keyboard... dunno the number, where can i find a list?
Dav

Re:interrupts

Post by Dav »

where can i find the intel docs?
http://developer.intel.com/design/pentium4/manuals/245470.htm
i also would like some more docs about idts
Bona Fide OS Development. Great site heaps of tutorials:
http://osdev.neopages.net/tutorials/interrupts.1.php
i bet there is an interrupt for keyboard... dunno the number, where can i find a list?
Ralf Browns Interrupt List:
http://www.ctyme.com/rbrown.htm
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:interrupts

Post by Pype.Clicker »

what do you mean with "i bet there is an interrupt for keyboard..." ? are you talking of the IRQ1 (hardware interrupt issued every time a key is pressed) or of the BIOS INT16h (which is a real-mode BIOS service and therefore not available in pmode) ?

The IRQ1 will be where you will re-program it (in realmode, the PIC maps IRQ0..7 to INT 8..F, but those interrupts are reserved for exceptions in pmode, so you have to re-map the interrupts using the 8259A -- iirc -- and move them to some other interrupts like, say, INT 0x20..0x27)
LOneWoolF

Re:interrupts

Post by LOneWoolF »

irq1, interrupt 09
can i use the interrupt number INT9, set to 0x20 in the IDT?

and a better question,
as I said
[tt]I'm not the biggest assambl-progger, most of my code will be in c[tt]:
how can i tell the assambler where the function shall be?

i have

Code: Select all

int_key:
...
call _interrupt_keyb
...
and the c function adds what happened in a queue and later it's printed...
Post Reply