Exercise · Volume 1 · 1.3.1-14
Exercise 1.3.1-14
not stated yet in Lean solution written
| Rating | 20 |
|---|---|
| Kind | K3, find a value: compute a number, a set or a closed form from the written solution |
| Section | Section 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 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 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 . The write of a sign only, , changes the cell if the sign differs. So no choice works in general. The two special operators are STJ and STZ.
STJ with 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 gives the value , so ADD and SUB with are no-ops (a sum with zero leaves a zero result with the same sign). Also the address with 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 and index change nothing. SLC and SRC with index and address a multiple of rotate by a whole turn of ten bytes and change nothing.
MOVE with moves no word, and rI1 is not changed, so it is a no-op that takes .
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 and index add and change nothing, even for . The forms ENT and ENN are not no-ops. For example ENT1 0,1 changes to 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 (NOP), (ADD), (SUB), (shifts), (MOVE), (STJ), (STZ), (JSJ) and to (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 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.