Re: Retired programmer wants to learn programming



In article <43E22B8D.3690913E@xxxxxxxxx>, cbfalconer@xxxxxxxxx says...
Gerry Quinn wrote:
cbfalconer@xxxxxxxxx says...

There is a major difference between creating an executable function
and modifying existing code. As an example, way back when, the
8080 had only i/o instructions of the immediate form "in port" and
"out port". This was not satisfactory for my purposes, so I wrote
a routine that received the value of port, created the sequence:

in port (or "out port")
ret
nop

on the stack, and called it. It then returned the result. Worked
just fine, was freely interruptible and re-entrant, etc. It was
minisculely slower than raw code, but avoided all sorts of
recompilation and/or assembly etc.

That IS self-modifying code. Your executable adds machine code to
itself, and executes it.

No it isn't. It has none of the disadvantages of
self-modification. The code is pure and re-entrant. Think of an
extremely small compiler and code generator buried within an
application.

It may be pure and re-entrant, but it is still self-modifying code.
Deal with it.

- Gerry Quinn



.