🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3975

Re: stealing an interrupt

#3975
From: Marc Brandis
Date: Tue, 18 Dec 1990 11:53
46 lines
2351 bytes
In article <90351.150210TOMIII@MTUS5.BITNET> TOMIII@MTUS5.BITNET (Thomas Dwyer III) writes:
>Hi there.  Would some kind soul please tell me why my machine hangs when
>I run this TSR?  What am I doing wrong?

[some stuff deleted]
>        assume  cs:code,ds:code,es:code
....
>        mov     word ptr [old_int+2],es         ; Save old vector
>        mov     word ptr [old_int],bx

Here, there is a rather unsafe assumption that ds points to the code segment
after DOS has been called. You should better set ds explicitly to code (e.g.
by push cs, pop ds) or use an segment prefix for cs. However, it is correct
in this place that ds points to code, it is just unsafe.

>        mov     ah,25h                          ; Set int vector
>        mov     al,INT_NUM
>        mov     dx,offset new_int

Once again, it would be better to set ds explicitly to the code segment.

....
>old_int dd      ?
>        jmp     [old_int]                       ; Jump to old int routine

Here lies the real problem. As this code is called inside an interrupt, the
assumption that ds points to code is wrong (!). You can either add a correct
assume statement in front of this code, which would be

		assume cs:code, ds:nothing, es:nothing, ss:nothing

or you can make it explicit that you want a segment prefix for this instruction
and that you want a far call, which is actually what I would suggest. It is
much better to make it explicit what is going on than to rely on the context
given by the assume statements. So try the following statement (the ultra safe
version)

	jmp	dword ptr cs:[old_int]

This should do what you want. 


Marc-Michael Brandis
Computer Systems Laboratory, ETH-Zentrum (Swiss Federal Institute of Technology)
CH-8092 Zurich, Switzerland
email: brandis@inf.ethz.ch
Technical Details
Message-ID: <18633@neptune.inf.ethz.ch>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcsun!cernvax!chx400!bernina!neptune!inf.ethz.ch!brandis
References: <90351.150210TOMIII@MTUS5.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcsun!cernvax!chx400!bernina!neptune!inf.ethz.ch!brandis
From: brandis@inf.ethz.ch (Marc Brandis)
Newsgroups: comp.os.msdos.programmer
Subject: Re: stealing an interrupt
Message-ID: <18633@neptune.inf.ethz.ch>
Date: 18 Dec 90 11:53:58 GMT
References: <90351.150210TOMIII@MTUS5.BITNET>
Sender: news@neptune.inf.ethz.ch
Reply-To: brandis@inf.ethz.ch (Marc Brandis)
Organization: Departement Informatik, ETH, Zurich
Lines: 46