Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!lll-winken!csustan!koko!jb From: jb@CSUStan.EDU (John Birchfield) Newsgroups: comp.lang.c Subject: Re: TSR's with TC Message-ID: <1098@koko.CSUStan.EDU> Date: 28 Aug 89 22:24:02 GMT References: <3723@ncsuvx.ncsu.edu> <69@tor.nhh.no> Reply-To: jb@koko.UUCP (John Birchfield) Organization: Calif. State Univ., Stanislaus, Turlock, Ca Lines: 66 In article <69@tor.nhh.no> edb_tom@tor.nhh.no (Tom Ivar Helbekkmo) writes: >In article <3723@ncsuvx.ncsu.edu>, sherman@csclea.ncsu.edu (Chris Sherman) writes: >> _chain_intr, which is usually used in an interrupt handler, accepts the >> address of another interrupt handler, and jumps (not calls) over to it. >> It is as if the first handler was never called. >> >No, you certainly can't do it that way. ... >Correct me if I'm wrong, someone, but unless Turbo C has explicit >support for writing interrupt handlers in C ... Turbo C allows writing interrupt handlers directly in C using pretty much the same mechanism as Microsoft. The following C program is provided as a very succinct example. ------------------------------------------------------------------------ /* * Turbo C Interrupt Handler Chaining Example * * You may easily see what your compiler thinks you mean for it to * do by compiling with the -S -c options and then looking at the * assembly code. * --- jb --- * Aug 28, 1989 #include void interrupt (*ticker_save) (); void interrupt ticker (); int count = 0; main () { ticker_save = getvect (8); setvect (8, ticker); while (count < 30); setvect (8, ticker_save); } void interrupt ticker () { count++; (ticker_save) (); } /* * The following is the pertinent assembly code generated by the * compiler inside ticker. Note that since the compiler knows about * the interrupt characteristics of the pointer ticker_save, * he pushes the flags before calling him. The only penalty you * have is the xtra registers pushed on the stack. Turbo C also * provides meta variables _AX _DX ... so that you can directly * manipulate the registers in the function. * * mov ds,bp * ; Line 17 * inc word ptr DGROUP:_count * ; Line 18 * pushf * call dword ptr DGROUP:_ticker_save * ; Line 19 */ ------------------------------------------------------------------------ - - === === John Birchfield 1575 Quail Ct. jb@koko.csustan.edu Turlock, CA 95380 (209) 634-6243