flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
c#6 21 Apr 2004, 13:32
Could someone explain to me how to use hardware interrupts? Primarily IRQ 6.
|
|||
![]() |
|
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. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.