Harvard vs. vonNeuman

From: Jim Battle <frustum_at_pacbell.net>
Date: Tue Sep 28 20:12:56 2004

Ron Hudson wrote:

...
> Can you create self modifying code in any high level language, the kind
> of code
> where the application program actually changes it's own instructions?

Back in high school I learned to program on a Wang 2200, which has only
BASIC, interpreted in microcode. Just for the entertainment value, I
wrote a program that would allow you to enter an arbitrary function as a
string and then would graph that function over the range specified.

It would have been possible to interpret that string to evaluate the
function at each point, but I did something relevant to the above question.

The 2200 had a block oriented tape system that allowed programs to read,
write, and step through blocks arbitrarily. I took the string that the
user hand entered, tokenized it, and wrote it out as a one line program
to the three blocks on the tape immediately following the graphing
program (program header block, program block, program trailer block).
The program would then OPEN the program just written, which would change
line 1000 which was something like

        1000 DEFFNY(X)=X

but with the right hand side replaced with the desired function.
Although writing out the function and reading it back in took four or
five seconds, the speed of the graphing more than made up for it.

This was about the time that I figured out that the only difference
between "protected" programs (can be run but not saved, listed, or
modified) was a single bit at the start of the block header. It took
about five lines of code to open a block, flip the bit, and write it
back, thereby defeating the protection.
Received on Tue Sep 28 2004 - 20:12:56 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:37:32 BST