🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #2810

Re: Self-modifying code

#2810
From: Michael Meissner
Date: Tue, 24 Oct 1989 16:40
47 lines
3200 bytes
In article <173@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen) writes:
>  Data General's MV Family has an 'execute accumulator' instruction. Very
>  useful when implementing a debugger.

The execute accumulator instruction is not as useful for implementing
a debugger as you might think.  First of all, it burns a register, and
since the machine only has four integer registers, this can be deadly,
particularly, since some of the character move instructions use all
four integer accumulators.  Second of all, if the instruction takes
more than one 16-bit word, the remaining words of the instruction are
the 16-bit words following the XCT instruction, which isn't terribly
useful.

About the only time I have ever seen the XCT used is for device
drivers to build I/O instructions, with the appropriate device code
inserted into the instruction.

The language runtimes, when they wanted to build instructions on the
fly, would build them on the stack (if running under AOS, AOS/VS or
RDOS) or in low memory (if running under native UNIX), insert a long
jump back to the next location, and jump to the location where the
instructions were built.

One place where self-mofifying code was used, was in the general
purpose SYS function under RDOS, AOS, and AOS/VS, which typically took
four arguments, an integer giving the system call number, and pointers
to three integer sized items that were copied to/from three
accumulators.  Except for native UNIX, system calls consisted of a
call instruction, followed by the system call number, error branch
location, and normal branch location.  The general SYS function would
have to build such a call on the fly.  Another place was generalized
functions that executed an user specified instruction.

In terms of debugger support, there is a BKPT instruction which the
debugger replaces the first 16-bits of the instruction.  When a BKPT
instruction is encountered, the registers are pushed, and the machine
jumps to the user breakpoint handler (most traps on the MV do not go
directly into the kernel, but jump to user trap handlers).  The
handler can then do whatever it wants, and it uses either the WPOPB
instruction to return if the BKPT instruction has been removed, or the
PBX instruction if the breakpoint is still active (Ac0 contains the
first 16-bits of the instruction to execute).
--

Michael Meissner, Data General.				If compiles where much
Uucp:		...!mcnc!rti!xyzzy!meissner		faster, when would we
Internet:	meissner@dg-rtp.DG.COM			have time for netnews?
Technical Details
Message-ID: <MEISSNER.89Oct24124016@tiktok.rtp.dg.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!xanth!mcnc!rti!xyzzy!meissner
References: <6481@pt.cs.cmu.edu> <9175@etana.tut.fi> <1619@atanasoff.cs.iastate.edu> <173@harald.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!xanth!mcnc!rti!xyzzy!meissner
From: meissner@dg-rtp.dg.com (Michael Meissner)
Newsgroups: comp.arch
Subject: Re: Self-modifying code
Message-ID: <MEISSNER.89Oct24124016@tiktok.rtp.dg.com>
Date: 24 Oct 89 16:40:16 GMT
References: <6481@pt.cs.cmu.edu> <9175@etana.tut.fi>
 <1619@atanasoff.cs.iastate.edu> <173@harald.UUCP>
Sender: usenet@xyzzy.UUCP
Organization: Data General (Languages @ Research Triangle Park, NC.)
Lines: 46
In-reply-to: jba@harald.ruc.dk's message of 16 Oct 89 09:40:13 GMT