Exercise · Volume 1 · 1.3.1-9
Exercise 1.3.1-9
not stated yet in Lean solution written
| Rating | 15 |
|---|---|
| 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
List the non-floating operators that can change the overflow toggle.
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 toggle is set by an operation that gives a result too big for a register, and tested or cleared by two jumps.
Hint 2
Check each family: arithmetic, address transfer, special, jumps.
Solution
Show the solution
Operators that set the toggle: ADD, SUB, DIV (a quotient too large or a zero divisor), NUM (a value too large for five bytes), INCA, DECA, INCX, DECX (the sum is too large for the register). Operators that read and clear it: JOV and JNOV. MUL cannot overflow, because the product has ten bytes. ENTA, ENTX and the load operators put a value that fits, so they never set the toggle. The index forms INCi and DECi do not set it: an overflow of an index register is undefined and is not shown by the toggle.
So the list is ADD, SUB, DIV, NUM, INCA, DECA, INCX, DECX, JOV, JNOV.
Check
python3 with : ADD of to gives , which does not fit, so the toggle goes on. The list has ten names.
Remarks
In Exercise 1.3.1-18 the toggle is set by an ADD in the middle of a program.
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.