🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #15770

Re: Memory Res. Prgs.

#15770
From: Bill Frolik
Date: Fri, 16 Jan 1987 17:12
47 lines
1937 bytes
If your memory resident program takes over some interrupt, one way for it to
determine if a copy of itself has already been made resident is to examine
the handler of any interrupt that it takes over:

		; replace "XX" with your favorite interrupt number

		org	100h
begin:		jmp	discard		;Jump over resident stuff

oldXX		dd	?		;
intXX:		nop			;Everything before the label
		nop			; "discard" will become resident
		nop			;
		jmp	far ptr cs:oldXX;

matlen		equ	$-intXX		;Match length for determing residency

discard:	xor	ax,ax		;ES ->
		mov	es,ax		; Segment zero
		les	di,es:[XX*4]	;ES:DI -> Current Int XX handler
		mov	si,offset intXX	;DS:SI -> Our new Int XX handler
		mov	cx,matlen	;Number of bytes that must match
		rep	cmpsb		;Compare the two handlers
		je	AlreadyThere	;Jump if they're the same

		; Our code has not yet been installed:
		; - Save old intXX vector in 'oldXX'
		; - Point intXX at our new routine 'intXX'
		; - Do anything else that may need to be done at install time

		mov	dx,offset discard	;Figure out
		add	dx,0Fh			; how many paragraphs
		mov	cl,4			; are to remain
		shr	dx,cl			; resident, then call
		mov	ax,3100h		; terminate/stay resident.
		int	21h

AlreadyThere:	; Our code has already been installed.

		mov	ax,4C00h		;Normal
		int	21h			; temination

Bill Frolik
hp-pcd!bill
Hewlett-Packard Portable Computer Division
Corvallis, Oregon
Technical Details
Message-ID: <1610003@hpcvlo.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!hplabs!hp-pcd!hpcvlo!bill
References: <1541@isis.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!hplabs!hp-pcd!hpcvlo!bill
From: bill@hpcvlo.HP.COM (Bill Frolik)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Memory Res. Prgs.
Message-ID: <1610003@hpcvlo.HP.COM>
Date: Fri, 16-Jan-87 12:12:46 EST
Article-I.D.: hpcvlo.1610003
Posted: Fri Jan 16 12:12:46 1987
Date-Received: Sun, 18-Jan-87 08:38:02 EST
References: <1541@isis.UUCP>
Organization: Hewlett-Packard Co., Corvallis, OR, USA
Lines: 47