I used to use a lot more self-modifying code in my early days then I do now,
you could save precious bytes of memory by storing data values into the
immediate operand of instuctions which used them --- I recall a "turning point"
when one day I spent a fair bit of time debugging a problem which was related
to two level deep self-modifying code - ie: Modified an instruction so that
it would subsequently modify another instruction differently - I started to
believe some of the nay-sayers about the evils of SM code after that :-)
Case where I've *HAD* to use SM code: 8080 general purpose monitor - no way
to read/write arbitrary I/O ports - have implemented it both as directly SM
code in RAM based monitor, and as a "built" subroutine in RAM for ROM based
monitor. Same for 8051 (except you have to overlay CODE and DATA address
spaces obviously - this is fairly normal for a debugging environment).
Cheers,
Dave
--
dave04a (at) Dave Dunfield
dunfield (dot) Firmware development services & tools:
www.dunfield.com
com Vintage computing equipment collector.
http://www.parse.com/~ddunfield/museum/index.html