alanr@tekigm2.MEN.TEK.COM (Alan Rovner) (04/17/89)
If I wanted to hook onto the keyboard interrupt handler to write my own TSR in assembly language how would I call the original handler(s) that were already in use? I understand that when grabbing onto an existing interrupt vector you should call however many functions have already been in use there. This is easy in C, one could call the function via a pointer, like (*orig_name)(). But I'm unclear how to do this in assembly language. I'm sure if there's a way to screw up the segment registers I'll find it. Again, any examples would be helpful. Thanks, Al Rovner Tektronix Inc. Vancouver, Wash.
jmv@sppy00.UUCP (Jim Vickroy) (04/18/89)
In article <4497@tekigm2.MEN.TEK.COM> alanr@tekigm2.MEN.TEK.COM (Alan Rovner) writes: => =>If I wanted to hook onto the keyboard interrupt handler to write my own =>TSR in assembly language how would I call the original handler(s) that =>were already in use? I understand that when grabbing onto an existing =>interrupt vector you should call however many functions have already been =>in use there. This is easy in C, one could call the function via a =>pointer, like (*orig_name)(). But I'm unclear how to do this in assembly =>language. I'm sure if there's a way to screw up the segment registers =>I'll find it. Again, any examples would be helpful. Try this: (example int16 - keyboard i/o) OLD_KEYBOARD LABEL DWORD OLD_KEYBOARD_OFF DW ? OLD_KEYBOARD_SEG DW ? : : MOV AX,3516H ; 'Get Interrupt Vector' 16H INT 21H ; DOS Function Call Interrupt MOV OLD_KEYBOARD_OFF,BX ; Save the offset MOV OLD_KEYBOARD_SEG,ES ; Save the segment : [stuff left out like grabbing and handling the interrupt] : JMP OLD_KEYBOARD ; Transfer control to the old ; handler You may have to use segment overrides if your program is sufficiently large. The equivalent to your C example [ (*orig_name)() ] would be: CALL ORIG_NAME **** Please note: You *would not* want to do this in a interrupt handler because the old handler is going to return via the IRET which will *not* transfer back to your handler. jim -- ============================================================================== :::: ::: :: :: : : Jim Vickroy |OC| ||| || || | | Technical Services Department |LC| ||| || || | | Online Computer Library Center, Inc. :::: ::: :: :: : : Dublin, Ohio ------------------------------------------------------------------------------ UUCP: {att|pyramid|killer}!osu-cis!sppy00!jmv domain: jmv@sppy00.uucp USSNAIL: 6565 Frantz Rd., Dublin, Ohio 43017-0702 ------------------------------------------------------------------------------ "Hey, wow man ... pooby shooby" -cm ==============================================================================