Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!ucsd!pacbell.com!att!emory!wa4mei!holos0!lbr From: lbr@holos0.uucp (Len Reed) Newsgroups: comp.os.msdos.programmer Subject: Re: stealing an interrupt Message-ID: <1990Dec19.172359.4140@holos0.uucp> Date: 19 Dec 90 17:23:59 GMT References: <90351.150210TOMIII@MTUS5.BITNET> <37017@cup.portal.com> Organization: Holos Software, Inc., Atlanta, GA Lines: 50 In article <37017@cup.portal.com> ekalenda@cup.portal.com (Edward John Kalenda) writes: >Thomas Dwyer write: => Hi there. Would some kind soul please tell me why my machine hangs when => I run this TSR? What am I doing wrong? = =The first problem that comes to mind is that your interrupt handling =routine is doing a jump to a location pointed to by an area in your =data segment. You should use JMP cs:[oldint] since the data segment =at the time the interrupt occurs will be that of the program running, =not your TSR. You're probobly jumping off into space somewhere based on =the value of ds:[oldint] in the current program's frame of reference. This analysis is correct but the solution is a little dangerous. I say this because I assume you're going to add code rather than leave your do-nothing skeleton in place. :-) Rather than putting the explicit "cs:" prefix in you should ensure that the in-effect "assumes" always match what's in the segment registers. Having done a lot of driver and TSR programming I can assure you that using explicit prefix overrides to save coding an "assume" will eventually lead to problems. Explicitly marking your assumes informs the assembler *and* the next programmer what you thought was in the segment registers. In your case, before the interrupt handler you should say: assume cs:code, ds:nothing, es:nothing, ss:nothing The assembler will then add the segment prefix for you. If it's not addressable you should get an assembly-time error. BTW, why do you embed your pointer to the saved handler inside your procedure? Just say ; [first part omitted here] mov ax,3100h ; terminate and stay resident int 21h ;NOT REACHED even ; word-align the data for efficiency old_int dd ? assume cs:code, ds:nothing, es:nothing, ss:nothing new_int proc far jmp [old_int] new_int endp -- Len Reed Holos Software, Inc. Voice: (404) 496-1358 UUCP: ...!gatech!holos0!lbr