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

Exercise 1.3.1-13

not stated yet in Lean solution written

Rating10
KindK2, decide: say whether a claim holds from the written solution
SectionSection 1.3.1 of Volume 1. Companion chapter: Description of MIX

The task

Decide how the behavior of the instruction at 1000 changes when JOV 1001 is replaced by three other jumps.

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

Recall: a jump that is taken sets rJ to the address of the next instruction. JOV and JNOV both clear the toggle.

Hint 2

Trace both cases: toggle on, toggle off.

Solution

Show the solution

Original JOV 1001. Toggle on: jump to 1001, rJ ←1001\leftarrow 1001, toggle off. Toggle off: no jump, next is 1001, rJ unchanged. The toggle is off after it.

JNOV 1001. Toggle off: jump to 1001, rJ ←1001\leftarrow 1001. Toggle on: no jump, the toggle goes off, rJ unchanged. In both cases the next instruction is 1001 and the toggle is off. But rJ changes in the other case. So the effect differs in rJ (when the toggle is on: the original sets rJ, the new one does not; when it is off: the opposite).

JOV 1000. Toggle on: jump to 1000, rJ ←1001\leftarrow 1001, toggle off. The instruction runs again and does not jump, so the next is 1001. Toggle off: same as the original. The only difference is 1u1u of extra time in the first case.

JNOV 1000. Toggle off: jump to 1000, the toggle is still off, so the jump repeats for ever. This is an infinite loop. With the toggle on: it clears the toggle and goes on to 1001.

Check

Table (toggle on at start): JOV 1001 gives rJ =1001= 1001; JNOV 1001 leaves rJ unchanged; JOV 1000 gives rJ =1001= 1001 and 2 steps; JNOV 1000 goes on to 1001. Toggle off at start: rJ unchanged, rJ =1001= 1001, rJ unchanged, infinite loop.

Remarks

A JNOV to its own address is a dangerous busy wait. Compare the use of JBUS * for input and output.

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.