Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!osu-cis!sppy00!jmv From: jmv@sppy00.UUCP (Jim Vickroy) Newsgroups: comp.sys.ibm.pc Subject: Re: Question 2 of 3 for assembly language programmers Keywords: How do you call existing interrupt handlers in ass'y? Message-ID: <298@sppy00.UUCP> Date: 18 Apr 89 15:07:04 GMT References: <4497@tekigm2.MEN.TEK.COM> Reply-To: jmv@sppy00.UUCP (Jim Vickroy) Distribution: na Organization: Online Computer Library Center, Dublin, Ohio. Lines: 53 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 ==============================================================================