Self modifying code, lambda calculus - Re: ENIAC programming
Paul Koning
paulkoning at comcast.net
Thu Sep 17 14:27:43 CDT 2015
> On Sep 17, 2015, at 2:56 PM, dwight <dkelvey at hotmail.com> wrote:
>
> What is the definition of self modifying?
> Is it changing an instruction to execute in the thread to be run?
> How about adding or subtracting something to be done in an execution
> queue?
I'm not sure if there is a universally agreed to definition.
It also matters why the question is asked. I can think of a couple of answers:
1. the contents of instruction memory is subject to change.
2. the contents of instruction memory is subject to change during execution of the program.
3. individual instructions in a program are changed by the execution of that program.
4. individual instructions in a program are changed by explicit data manipulation actions of that program.
#1 is true for most computers past and present, because they allow a program to be loaded into memory from external storage.
#2 is true in any program that uses overlays, or if the program is controlled by a debugger that uses "software breakpoints".
#3 is true for some older ISAs where subroutine call writes a return address or jump back to the caller into the program address space. Examples are CDC 6000 systems (CPU and PPU).
#4 is perhaps the best definition to capture the particular programming style that was once common and is now quite rare (though not quite extinct). It might be as simple as modifying the address field of an opcode, to do indexing when the ISA does not have indexing instructions or registers. Or it might be something trickier, where a function does one of two similar things depending on an argument passed in, which then causes the body of the function to be modified in the prologue.
There's a bizarre variant of #3 seen in the Electrologica EL-X1, where there is an addressing mode ("C") that adds the B-register contents to the base address that's in the opcode, but then writes the resulting address back into the instruction. (So doing repeated C mode operations with B == 1 will walk through consecutive addresses in memory, leaving the code pointing at the first word after the end of the buffer referenced.) Needless to say, this makes no sense, was probably in practice rarely if ever used, and disappeared in the successor to that machine (the EL-X8 -- where the same opcode encoding was used for stack addressing, with B incremented or decremented to produce the standard stack access patterns). See Dijkstra's Ph.D. thesis for details.
paul
More information about the cctalk
mailing list