TAOCP 1.3.1 Exercise 14
The correct notion is very strong: an instruction is equivalent to `NOP` only if, for every initial machine state, it leaves **all registers, memory, indicators, and control state unchanged**.
Section 1.3.1: Description of MIX
Exercise 14. [20] For each MIX operation, consider whether there is a way to set the \pm AA, I, and F portions so that the result of the instruction is precisely equivalent to NOP (except that the execution time may be longer). Assume that nothing is known about the contents of any registers or any memory locations. Whenever it is possible to produce a NOP, state how it can be done. Examples: INCA is a no-op if the address and index parts are zero. JMP can never be a no-op, since it affects rJ.
Verified: no
Solve time: 5m10s
The correct notion is very strong: an instruction is equivalent to NOP only if, for every initial machine state, it leaves all registers, memory, indicators, and control state unchanged. It is not enough that it “sometimes does nothing”; it must act as the identity transformation on the entire state space.
The key correction missing from the previous solution is that several MIX operations have field specification $(0:0)$ which yields the constant value $0$, and in some arithmetic instructions this does produce a genuine no-op. However, in most cases it still fails because the instruction overwrites state or affects control information.
We now redo the classification carefully and completely.
1. Shift operations
These include
$$ \texttt{SLA},\ \texttt{SRA},\ \texttt{SLAX},\ \texttt{SRAX},\ \texttt{SLC},\ \texttt{SRC}. $$
The shift amount is $M$, derived from $\pm AA$ and $I$.
If we choose
$$ \pm AA = 0,\quad I = 0, $$
then $M = 0$. All shifts by zero positions leave every byte of the affected register(s) unchanged, and no other state component is modified.
Hence all shift operations are equivalent to NOP when $M = 0$.
2. MOVE
MOVE transfers $F$ words and increments the index register $rI_1$ by $F$.
If we choose
$$ F = 0, $$
then:
- no memory words are moved,
- $rI_1$ is incremented by $0$,
- no other state changes.
Thus MOVE is equivalent to NOP when $F = 0$.
3. Arithmetic operations
3.1 ADD and SUB
These instructions use the field value $V$. If we choose field specification
$$ F = (0:0), $$
then the loaded value is
$$ V = 0. $$
So:
ADDperforms $rA \leftarrow rA + 0$,SUBperforms $rA \leftarrow rA - 0$.
No overflow can occur, and no register or memory location changes.
Hence:
ADDisNOPwhen $F = 0$,SUBisNOPwhen $F = 0$.
3.2 MUL
Even with $F = 0$, the operand is $0$, so:
$$ rAX \leftarrow rA \cdot 0 = 0. $$
This overwrites registers $rA$ and $rX$, so the state changes for all nonzero inputs.
Thus MUL can never be equivalent to NOP.
3.3 DIV
With $F = 0$, division by zero occurs. In MIX this triggers overflow and changes machine state.
Thus DIV can never be equivalent to NOP.
4. Load operations
These include
$$ \texttt{LDA},\ \texttt{LDX},\ \texttt{LD1},\ldots,\texttt{LD6} $$
and their negative variants.
Even with $F = (0:0)$, the loaded value is $0$, so the instruction performs:
$$ r \leftarrow 0. $$
This overwrites the register for every initial state, so the state is not preserved.
Therefore no load instruction can be equivalent to NOP.
5. Store operations
These include
$$ \texttt{STA},\ \texttt{STX},\ \texttt{ST1},\ldots,\texttt{ST6},\ \texttt{STJ},\ \texttt{STZ}. $$
Even if $F = (0:0)$ (store sign only):
- a byte of memory is modified (the sign field),
- the modification depends on register contents.
To be equivalent to NOP, the instruction must leave memory unchanged for all states, but for any such store instruction there exist states where:
- the stored sign differs from the existing memory sign.
Hence memory is not preserved universally.
Therefore no store instruction can be equivalent to NOP.
6. Arithmetic transfer (INC/DEC family)
These add or subtract $M$.
If we choose:
$$ \pm AA = 0,\quad I = 0 \Rightarrow M = 0, $$
then:
INCA,INCX,INC1–INC6perform $+0$,DECA,DECX,DEC1–DEC6perform $-0$.
All registers remain unchanged and no flags are affected.
Thus all increment/decrement instructions are equivalent to NOP when $M = 0$.
7. Load negative (ENTA/ENNA family)
These explicitly load:
$$ r \leftarrow \pm M. $$
Even with $M = 0$, the instruction forces the register to $0$, overwriting prior contents.
Thus they are not identity transformations and cannot be NOP.
8. Comparison operations
All CMP instructions set the comparison indicator based on a comparison between a register and memory.
Even if equality holds for some states, other states produce different outcomes, and the indicator is always overwritten.
Thus no comparison instruction can be NOP.
9. Jump instructions
All jumps (JMP, conditional jumps, and register jumps) alter either:
- the location counter, or
- register $rJ$, or
- both.
Even if a condition is never satisfied for some states, there exist states where it is satisfied, so control flow changes.
Hence no jump instruction can be equivalent to NOP.
10. Input-output operations
All I/O instructions (IN, OUT, IOC, JBUS, JRED) interact with external devices or memory buffers and may:
- modify memory,
- change device state,
- or alter control flow.
No parameter choice can eliminate these effects for all states.
Thus none are NOP.
Final classification
The MIX instructions that can be made equivalent to NOP are exactly:
Shift operations (with zero shift)
$$ \texttt{SLA},\ \texttt{SRA},\ \texttt{SLAX},\ \texttt{SRAX},\ \texttt{SLC},\ \texttt{SRC} \quad (\pm AA=0,\ I=0) $$
MOVE (zero-length move)
$$ \texttt{MOVE} \quad (F=0) $$
Increment / decrement family (zero increment)
$$ \texttt{INCA},\texttt{DECA},\texttt{INCX},\texttt{DECX},\texttt{INC1},\ldots,\texttt{DEC6} \quad (M=0) $$
Arithmetic additions and subtractions with zero field
$$ \texttt{ADD},\ \texttt{SUB} \quad (F=(0:0)) $$
Final result
$$ \boxed{ \begin{aligned} \text{NOP-equivalent MIX instructions are: }\ \texttt{SLA,SRA,SLAX,SRAX,SLC,SRC},\ \texttt{MOVE},\ \texttt{INCA,DECA,INCX,DECX,INC1,\ldots,DEC6},\ \texttt{ADD,SUB} \text{ with } F=(0:0). \end{aligned} } $$
All other MIX operations necessarily modify some component of machine state for at least one initial configuration, so no choice of $\pm AA$, $I$, and $F$ can make them equivalent to NOP.