I remember using a simulated machine with with a minimal instruction set in university. In particular I remember that the instruction that consisted of all zeroes loaded was a LOAD
instruction. So, if you made a mistake and began executing empty memory then it would simply keep executing until it ran out of address space.
x86
appears to perform an ADD
on empty memory, so similar behaviour to the example above.
All zeros in 6502
on the other hand, corresponds to the BRK instruction which activates a software interrupt so executing empty memory quickly puts the machine in a known state.
My understanding is that 6502
was designed to be written by humans, whereas (at least modern) x86
is designed for compilers to output. Historically, when a machine instruction set is designed, how much attention has been paid to the specific representation each instruction has, given that it can have real effects? I've focused on what the all-zeroes instruction does because I expect that would be the most common instruction to be accidentally executed, but I'd be interested in considerations relating to other instruction representations as well.
BRK
as opcode 0 in 6502 was done to simplify hardware: internally the processor handles an external interrupt by shorting the bits of the next opcode to ground when it starts decoding it, and therefore causing the interrupt handling system to be invoked. The Intel 8080 (and hence Z80) also has a similar design decision involving the bit patterns of theRST
instructions, in this case to simplify external circuits producing them rather than a circuit internal to the processor; the 8080's zero instruction however is explicitly designatedNOP
. $\endgroup$ – Jules Jan 2 '18 at 9:14