flat assembler
Message board for the users of flat assembler.

Index > Main > Hardware interrupts

Thread Post new topic Reply to topic

Joined: 20 Apr 2004
Posts: 25
c#6 21 Apr 2004, 13:32
Could someone explain to me how to use hardware interrupts? Primarily IRQ 6.
Post 21 Apr 2004, 13:32
View user's profile Send private message Reply with quote
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 21 Apr 2004, 18:08
hardware interrupts are just like other interrupts, only difference is they are trigerred by IRQ, not by INT instruction. You also have to play a little with IRQ in the beggining and end of interrupt to prevent double call etc., but this depends on which interrupt are you going to use.
Post 21 Apr 2004, 18:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote

Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas 24 Apr 2004, 07:13
Hardware interrupts are automatically called when something happens to the hardware connected to them. (i.e.: if it is the timer, every timer tick; if it is the keyboard, every time a key is pressed or released). If you need to "capture" something in the moment of happening, you hang at one of these interrupts. To do this, consider that every IRQ has a software interrupt assigned to it. For IRQ0 (timer) the interrupt is 8, for IRQ1 (keyboard), interrupt is 9, and so on. So, in your case, for IRQ6 (diskette drive), interrupt will be 0Eh, I suppose. So, you change the interrupt 0Eh vector and point it to your routine, but, you must not eliminate the previous handler, you should, instead, JUMP to it as soon as you finish your job. In the case that sometime you would NOT jump to the old handler, you should perform the following instructions before leaving the interrupt with an IRET:

mov al,20h
out 20h,al

That is, OUT a 20h to port 20h. That is something like a petition to initialize the interrupt controller or something like that. Believe me, if you don't do that, very likely, your system will crash. Mine does!
And remember: IRQs are executed at any moment, in the ladder of any code, so you'd better save all the registers you're willing to change and restore them before leaving the interrupt.
One last thing: don't put very long code there, and if you do, enable interrupts... but that is more complex.
Post 24 Apr 2004, 07:13
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.