taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.3.1-14

Exercise 1.3.1-14

not stated yet in Lean solution written

Rating20
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.3.1 of Volume 1. Companion chapter: Description of MIX

The task

For each MIX operator, find out whether some choice of address, index and field makes it behave exactly as NOP, and give the choice.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

The register contents and the memory are unknown, so the instruction must leave every register, indicator and cell as it is, whatever they hold.

Hint 2

Go through the operators in the order of Table 1 of Section 1.3.1. For each one list what it changes, and ask if some field or address makes that change empty.

Hint 3

For stores, remember that the cell MM may be the cell that holds the instruction itself.

Solution

Show the solution

Plan: an operator is a no-op only if everything that it changes can be made empty. Check each family.

Loads (LDA, LDi, LDX, and the N forms) always put a value in a register, and the value depends on memory. Nothing is known about the register, so no choice works. For LDi, a field that gives +0+0 does not help for the same reason.

Stores of a register (STA, STi, STX) write a field of memory. A field that is empty does not exist, because L≤RL \le R. The write of a sign only, (0:0)(0:0), changes the cell if the sign differs. So no choice works in general. The two special operators are STJ and STZ.

STJ with (0:0)(0:0) and address ∗* (the place of the instruction itself) writes the sign ++ of rJ into the sign of the instruction, and that sign is already ++ (the address ∗* is positive). So STJ *(0:0) is a no-op. STZ *(0:0) is a no-op for the same reason. STZ *(3:3) clears byte 3 of its own word, the index field, which is already zero. So it is a no-op.

ADD and SUB: the added value must be zero. The field (0:0)(0:0) gives the value +0+0, so ADD and SUB with F=(0:0)F = (0:0) are no-ops (a sum with zero leaves a zero result with the same sign). Also the address ∗* with F=(3:3)F = (3:3) adds byte 3 of the instruction, which is zero.

MUL, DIV, NUM, CHAR always change rX (or rA and rX), so they are never no-ops.

HLT stops the machine, and the stop is an effect, so HLT is not counted as a no-op.

Shifts. SLA, SRA, SLAX, SRAX with address 00 and index 00 change nothing. SLC and SRC with index 00 and address a multiple of 1010 rotate by a whole turn of ten bytes and change nothing.

MOVE with F=0F = 0 moves no word, and rI1 is not changed, so it is a no-op that takes 1u1u.

Jumps. Each taken jump changes rJ, except JSJ. JSJ *+1 goes to the next instruction and does not change rJ, so it is a no-op. All other jumps are not no-ops: JMP and the conditional jumps set rJ when they jump to the next instruction, and when they do not jump, the jump may take place, because the registers are unknown. JOV and JNOV also clear the toggle.

INCA, DECA, INCX, DECX, INCi, DECi with address 00 and index 00 add 00 and change nothing, even for −0-0. The forms ENT and ENN are not no-ops. For example ENT1 0,1 changes −0-0 to +0+0 in rI1.

The comparison operators always change the comparison indicator, so they are never no-ops. IN, OUT, IOC, JBUS and JRED act on a device or on rJ, so they are not no-ops either.

Check

The operation codes that have a no-op form are 00 (NOP), 11 (ADD), 22 (SUB), 66 (shifts), 77 (MOVE), 3232 (STJ), 3333 (STZ), 3939 (JSJ) and 4848 to 5555 (INC, DEC of the registers A, I1 to I6 and X). The python test len({0,1,2,6,7,32,33,39} | set(range(48,56))) gives 1616 codes.

Remarks

Only sixteen of the sixty-four operation codes have a no-op form. A real NOP is also used to give a label to a place where no instruction is needed, as in Section 1.3.2.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.