Re: Compiler and interpreter origins

Martin Ward <Martin.Ward@durham.ac.uk>
10 Aug 2004 17:31:16 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Compiler and interpreter origins rweaver@ix.netcom.com (Dick Weaver) (2004-08-05)
Re: Compiler and interpreter origins gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-08-05)
Re: Compiler and interpreter origins rbates@southwind.net (Rodney M. Bates) (2004-08-09)
Re: Compiler and interpreter origins nick.roberts@acm.org (Nick Roberts) (2004-08-09)
Re: Compiler and interpreter origins nmm1@cus.cam.ac.uk (2004-08-09)
Re: Compiler and interpreter origins slimick@venango.upb.pitt.edu (John Slimick) (2004-08-09)
Re: Compiler and interpreter origins Martin.Ward@durham.ac.uk (Martin Ward) (2004-08-10)
Re: Compiler and interpreter origins samiam@moorecad.com (Scott Moore) (2004-08-10)
Re: Compiler and interpreter origins beliavsky@aol.com (2004-08-11)
Re: Compiler and interpreter origins david.thompson1@worldnet.att.net (Dave Thompson) (2004-08-23)
Re: Compiler and interpreter origins jeremy.wright@microfocus.com (Jeremy Wright) (2004-08-25)
Re: Compiler and interpreter origins torbenm@diku.dk (2004-09-03)
Re: Compiler and interpreter origins gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-09-07)
| List of all articles for this month |
From: Martin Ward <Martin.Ward@durham.ac.uk>
Newsgroups: comp.compilers
Date: 10 Aug 2004 17:31:16 -0400
Organization: Compilers Central
References: 04-07-077 04-08-028
Keywords: history, comment
Posted-Date: 10 Aug 2004 17:31:16 EDT

On Thursday 05 Aug 2004 7:27 pm, you wrote:
> [The IBM 360 architecture specifically permits instruction modification
> without extra serialization. I gather it's still a pain for hardware
> implementers, although it's now much more common to do an EXecute
> instruction to run one instruction created at runtime. -John]


Self-modifying code is common in IBM assembler code in daily use today.
The most common form is a NOP modified to a branch instruction,
for example:


LABEL1 NOP LABEL2
OI LABEL1+1,X'FO'


The Or-Immediate changes the second byte of the NOP: converting
the instruction from a "branch never" to a "branch always".
You save one bit of memory and a whole compare instruction!


The EXecute instruction loads the target instruction into memory,
overwrites part of it with the contents of a register, and executes
the result. It is most often used to produce a variable length move.
But I have seen EXecute used as a sort of one-instruction
subroutine call: EX is only four bytes, so if you use EX to EXecute
a six byte instruction, then you are saving two bytes!


--
Martin


Martin.Ward@durham.ac.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
[Eeeww. I didn't even do that back in 1970. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.