Xref: utzoo comp.sys.ibm.pc:38329 comp.lang.pascal:2688 Path: utzoo!attcan!sobmips!uunet!mcsun!inria!geocub!pelegrin From: pelegrin@geocub.greco-prog.fr Newsgroups: comp.sys.ibm.pc,comp.lang.pascal Subject: Re: chaining interrupts Message-ID: <1484@geocub.greco-prog.fr> Date: 15 Nov 89 20:05:35 GMT References: <4543@solo5.cs.vu.nl> Sender: news@geocub.greco-prog.fr Reply-To: pelegrin@goofi.UUCP (Uncle Ben's) Organization: ENSERB 351 Cours de la Liberation 33405 TALENCE tel 56 84 65 00 Lines: 47 It is absolutely harmless to link interrupt routines one to another WITH THE SAME INTERRUPT VECTOR provided that, for interrupts such as timer ticks, the total amount of time spent in the routines does not exceed the tick clock rate... A general example of a resident interrupt routine installation program (machine language) is given below : Initialization routine : 1) Save the old interrupt vector (INT 21H, FCN 25H) in a double word variable named, i.e. OLDVEC (defined with "DD OLDVEC"). 2) Set the new interrupt vector (INT 21H, FCN 35H) to the segment:offset of your own interrupt routine NEWVEC, located within this program. 3) Make the program resident, including this routine (which will now be of no use but we have no way to eliminate it), and the next routine : Interrupt routine (starting at address NEWVEC) : 1) Push the registers you will use in your routine. 2) Perform whatever you want to... (8^D). Since it is an interrupt routine, DS and ES may have any value ; for small use of local variables, use the CS: prefix to access them within your code segment, else push DS and/or ES and set them equal to CS (for example...). If you use a large amount of stack, you can also switch to your own local stack. 3) Pop the registers you pushed before, in reverse order. 4) Use the JMP OLDVEC mnemonic (inter-segment jump from a memory operand) to link to the old interrupt vector. If you want to bypass the old interrupt vector, just perform at step 4) a single IRET mnemonic for software interrupts, but if it was a hardware interrupt (issued thru a Programmable Interrupt Timer), NEVER forget to use the EOI mnemonic to warn the PIT of the end of the interrupt (for such cases, I *strongly* recommend to link your interrupt to the previous one, so that you don't have to hold those stinky cases...). Have fun. f.p. ------------------------------------------------------------------------------ ! Zeu : The craziest programmer in France ! _________ ! !---------------------------------------------! / | \ \ ! ! Francois Pellegrini is : ! / |__ ___/ \ ! ! pelegrin@goofi.greco-prog.fr ! \ | | / ! ! uunet!mcsun!inria!geocub!goofi!pelegrin ! \ | | / ! ! pelegrin@goofi.UUCP ! ! ------------------------------------------------------------------------------