Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!accuvax.nwu.edu!midway!valley From: valley@uchicago (Doug Dougherty) Newsgroups: comp.os.msdos.programmer Subject: Re: stealing an interrupt Message-ID: Date: 18 Dec 90 19:59:04 GMT References: <90351.150210TOMIII@MTUS5.BITNET> <18633@neptune.inf.ethz.ch> Sender: news@midway.uchicago.edu (News Administrator) Organization: University of Chicago Lines: 29 brandis@inf.ethz.ch (Marc Brandis) writes: >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. Oh, come on. You can surely assume two things: 1) DS = CS on entry to a COM program 2) No DOS call is gonna change DS (unless explicitly stated in the documentation; I can't imagine that any do as of this writing) Yes, it is a good idea to be a little paranoid (maybe a lot paranoid) when doing assembly language programming, but you are taking it too far. But then again, you probably code in MASM or TASM or something like that, so it figures you'd be a little paranoid about segment registers...