Subj : Re: A really stupid Question - how to build a library To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Fri Oct 08 2004 11:35 am There are three kinds of interrupt - ones generated by problems such as an invalid op-code (a kind that we need not deal with here) - ones generated by a software instruction (called software interrupts) - ones generated by signal at the processor's pins (called hardware interrupts). Interrupts are hardware assisted pre-emptive call instructions. They wait for the current instruction to finish (for a step in the current one for some instructions), save the processing address on the stack and transfer control to an address whose value is an entry in a table called the interrupt vector table. Each interrupt number has an entry in the table, a table whose entries DOS set as it was initializing. Most operating system functions under DOS are invoked by generating a software interrupt and most of them involve interrupt 0x21 with a value in the AH register specifying what function is to be performed. This is called a DOS interrupt or more often a DOS function call. When your DAC board generates an interrupt, control transfers to the address in the interrupt vector table for that interrupt. Normally that would be a set of code that merely returns from interrupt (code that executes an IRET instruction). To ask DOS to set an interrupt vector one places 0x25 into the AH register, the interrupt number into the AL register, the interrupt vector (address) into the DS and DX registers and do a DOS call, generate a 0x21 interrupt (INT 0x21 or geninterrupt(0x21)). Note that the DS register is used by your program for the segment address for your data segment (base address of the up to 64K data block divided by 16) so one normally has to push DS onto the stack, set the value for the vector, do the DOS call, then pop the value of DS off of the stack to restore it. To ask DOS to give you the current value of the interrupt vector you place 0x35 in the AH register, the interrupt number in the AL register and do a DOS call. The interrupt vector is returned in the ES and BX registers. The compiler provides functions to set and get interrupt vector values, the functions setvect and getvect. They deal with the vagarities of what registers need be saved and restored and calling DOS. An example of a program which uses interrupts for serial communications under DOS is here: (not the best code, way too much processing in the interrupt - it's meant as an example for how things are done, not intended to illustrate production code) ftp://ftp.nsk.su/pub/text-doc/ti/bc_cpp/ti445.zip That is part fo the TI (Tech Info Document) archive at this page: http://ftp.nsk.su/cgi-bin/bbs2html?pub/text-doc/ti/bc_cpp .. Ed > dkat wrote in message > news:41661247@newsgroups.borland.com... > > OK, this is where I have a serious flaw in my understanding of > how things work. I had thought I could only have one ISR in my > library for any particular interrupt since I had thought > declaring it basically started it up.... I can't really wrap > my head around this one... must think on it longer. The ISR > doesn't get called as a function or routine in the program - it > gets called by the interrupt.... that is it is event driven > rather than bumped off the stack (yes I'm using made up jargon > ....). So what I would do would be have different > initialization routines that would trigger different ISRs... > (really sorry about not having the correct wording here. Am I > close? .