[micro.ibm] Intercepting a PC interrupt

tcamp@ecsvax.UUCP (06/04/87)

I need some help writing a routine to intercept a PC interrupt.

The interrupt I want to intercept is 1Ch--the user-available
clock tick.  I want to do some things in the background.  I want
to call a c function from this interrupt.  I'm using Mark 
Williams C on IBM-compatible machine.

So far I have written an assembly-language routine that saves
the registers, restores the DS register to that of my program
area (where the c routines are), calls the C function, then
restores the registers before issuing an IRET instruction.  

When I call a null, or simple, c function, this seems to work 
o.k.  But when a call a slightly more complex function which 
in turn calls a function which passes parameters on the stack, the stack
stack seems to get clobbered, and the thing fails.  

I'm not sure if this is because (a) I need to set up a new stack
every time the interrupt routine is issued (any suggestions?) or
(b) the intercept routine is now so large that it is being interrupted 
by itself.  Maybe I should CLI and disable interrupts, but when I try
this in the routine, nothing seems to work.  

This probably sounds like a hopeless mess.  Any suggestions as to 
diagnostics or possible remedies?

-Ted A. Campbell
 Duke University
 Durham, NC  
 email:  tcamp@ecsvax