Exercise · Volume 1 · 1.3.1-8
Exercise 1.3.1-8
not stated yet in Lean solution written
| Rating | 15 |
|---|---|
| Kind | K8, compute by machine: find a number or an object by a large computation from the written solution |
| Section | Section 1.3.1 of Volume 1. Companion chapter: Description of MIX |
The task
Compute rA and rX after the DIV of the section when the dividend has the bytes and a minus sign.
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 cell holds , the number , and rA is before the instruction.
Hint 2
Only the magnitude of rAX matters for the quotient. Write the dividend as a polynomial in .
Solution
Show the solution
The dividend has the magnitude
and the divisor has the magnitude . Now
because , , , and . The remainder is less than . So the quotient is , with the bytes . The remainder has the bytes .
The signs: rA and the cell are both negative, so rA becomes . The sign of rX is the old sign of rA, which was . The result is
The result does not depend on .
Check
python3 with divmod(12*b**4+34*b**3+3*b+1, 2*b) for and gives digits and in both cases.
Remarks
In the original example the byte pair is , and the odd byte leaves the half byte in the quotient, so there the result depends on . This is why the table shows question marks there.
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.