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-9

Exercise 1.3.1-9

not stated yet in Lean solution written

Rating15
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

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 b=64b = 64: ADD of b5−1b^5 - 1 to 11 gives b5b^5, 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.