Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!amdahl!pyramid!prls!mips!wyse!vsi1!altnet!uunet!mcvax!ukc!dcl-cs!nott-cs!anw From: anw@nott-cs.UUCP Newsgroups: comp.arch Subject: Re: Self-modifying code Message-ID: <572@tuck.nott-cs.UUCP> Date: 20 Jul 88 18:16:06 GMT References: <5254@june.cs.washington.edu> <76700032@p.cs.uiuc.edu> <1276@edge.UUCP> <361@scolex> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Department of Mathematics, The University, NOTTINGHAM, NG7 2RD, UK. Lines: 36 The Manchester University ATLAS, on which I cut my teeth (violins), included in its standard (ABL) Assembler a most extraordinary example of SMC. Each 48-bit instruction consisted of a 10-bit opcode, two 7-bit register numbers and a 24-bit address. If the MSB of the opcode was 1, the operation was an extracode, essentially one of 512 hard-wired subroutines [trig fns, complex arith, double arith, tape motions, I/O, etc, and how 512 such subroutines were squeezed into 4096 words, shared with a compiler, supervisor, test routines etc is another gory story]. If it was 0, then the next bit was ignored, and the following two bits determined the type of operation (00 illegal, 01 integer, 10 test, 11 floating). ABL included 128 user-settable flags. Where were these stored? Where else but in the ignored bits of 128 consecutive instructions within ABL itself which happened not to be extracodes. I remember being amazed by the discovery. I'm still not sure whether one should be appalled, or whether one should marvel at the ingenuity. All those people who were recently distrustful of an optimising assembler would have been really dubious about a self-modifying assembler! I once, and only once, wrote SMC myself. Also on ATLAS. It was a self-initialising random number generator. First time through, it initialised itself, either from the clock or from the user-supplied seed, then pulled the real code in on top of itself. Must have saved 3us per call, may well have amounted to 0.1% of the total run-time in heavy simulations. I was proud of it at the time. ATLAS would be a fine candidate for Bob Webber's collection of historic computers for which there ought to be simulations. I still have a cupboard full of machine-code listings of most of the important software. -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk