Noel Chiappa writes:
The thing is that self-modifying code is pretty much
an artifact of the dawn
of computers, before the economics of gates moved from that of tubes, to
transistors, and also before people understood how important good support for
subroutines was. (This latter is a reference to how Whirlwind did subroutines,
with self-modifying code.) Once people had index registers, and lots of
registers in general, self-modifying code (except for a few small, special
hacks like bootstraps which had to fit in tiny spaces) became as dead as the
dodo.
It's just a Bad Idea.
The one practical and Good Idea place for self-modifying code that I
encountered was the software implementation of floating-point for
516-TSS runnning on the Honeywell 516. Our code modified the count
in the shift instructions for normalization. Any other approach would
have involved looping. Granted, an instruction set that took the
shift count from a separate register would have made this unnecessary
but that's not what the 516 had.
Jon