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

Exercise 1.3.1-19

not stated yet in Lean solution written

Rating14
KindK8, compute by machine: find a number or an object by a large computation from the written solution
SectionSection 1.3.1 of Volume 1. Companion chapter: Description of MIX

The task

Find the total running time of the program of Exercise 1.3.1-18, without the final HLT.

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

Use the time column of Table 1 of Section 1.3.1: the time of each operator in uu.

Hint 2

The program has fifteen instructions before the HLT. Only NUM, CHAR and MOVE are not 1u1u or 2u2u.

Solution

Show the solution

The times in order are STZ 2, ENNX 1, STX 2, SLAX 2, ENNA 1, INCX 1, ENT1 1, SRC 2, ADD 2, DEC1 1, STZ 2, CMPA 2, MOVE 1+2⋅1=31 + 2 \cdot 1 = 3, NUM 10, CHAR 10. The sum is

2+1+2+2+1+1+1+2+2+1+2+2+3+10+10=42.2+1+2+2+1+1+1+2+2+1+2+2+3+10+10 = 42.

The running time is 42u42u.

Check

In the simulator the time after the last CHAR is 42u42u, and the HLT adds 1u1u more (43u43u in all). The sum was computed in python: sum([2,1,2,2,1,1,1,2,2,1,2,2,3,10,10]) = 42.

Remarks

A time of 42u42u is the same for each bb, because no instruction depends on the contents of the words.

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.