nyef wrote:
Okay, how about having some way to modify the next instruction in the stream by ORing (or XORing) in some bitmask?
Cool suggestion, nyef! The
Apollo Guidance Computer used a feature like this, although I'm having trouble finding the doc I read years ago which laid out the specific details.
The feature in question used addition, not ORing or XORing, but the intent was similar. Prior to execution, but subsequent to being fetched from memory, an instruction could be modified by adding a value computed at run time. It was a sanitized version of self-modifying code. IIRC the main intent was simply to implement indexed addressing. The addition was expected to modify an Address Field located in the bottom of the instruction word.
That's clever in itself, but a fascinating quirk yielded capabilities far beyond what had been originally planned. Someone realized that an addition could also or alternatively modify the Opcode Field in the
top of the instruction word. Moreover, such an addition would produce an n+1 bit result -- a carry. This anomaly was recognized as an opportunity.
The carry was decoded along with the original opcode bits, and the opcode space was thus doubled. A whole new set of instructions could then be defined -- instructions which were only available via this curious back door technique!
cheers
Jeff