Exercise · Volume 1 · 1.3.1-19
Exercise 1.3.1-19
not stated yet in Lean solution written
| Rating | 14 |
|---|---|
| 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
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 .
Hint 2
The program has fifteen instructions before the HLT. Only NUM, CHAR and MOVE are not or .
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 , NUM 10, CHAR 10. The sum is
The running time is .
Check
In the simulator the time after the last CHAR is , and the HLT adds more ( 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 is the same for each , 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.