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.4.3.1-8

Exercise 1.4.3.1-8

not stated yet in Lean solution written

Rating20
KindK2, decide: say whether a claim holds from the written solution
SectionSection 1.4.3.1 of Volume 1. Companion chapter: A MIX simulator

The task

True or false: whenever line 010 of the simulator is executed, 0≤rI6<BEGIN0 \le \text{rI6} < \text{BEGIN}.

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

How can rI6 get a new value? Look at the places where it is changed.

Hint 2

What happens after the instruction at the last location of the simulated memory, if it is not a jump?

Solution

Show the solution

False. The value rI6 is the location of the next simulated instruction. It is set by ENT6 0 at the start, increased by one at line 012, and set to MM by JSJ at line 255. The jump goes only to an MM that MEMORY has checked, so M<BEGINM < \text{BEGIN}. The only way to get a value of rI6 outside the range is the increase by one. This can give rI6=BEGIN\text{rI6} = \text{BEGIN}, when the simulated program has no jump at location BEGIN−1\text{BEGIN} - 1 and goes on to the next location. Then line 010 loads the word at location BEGIN, which is the first instruction of the simulator, STZ TIME(0:2). The simulated instruction has an address that is not in the simulated memory, so the next step is a MEMERROR. The statement is true for the weaker form 0≤rI6≤BEGIN0 \le \text{rI6} \le \text{BEGIN}, because the value can not go higher: a MEMERROR stops the program before the next increase.

Check

I ran the simulator on a MIX simulator with the simulated program JMP 3499 at location 0. The location 3499 holds a NOP. After it, line 010 was executed with rI6=3500=BEGIN\text{rI6} = 3500 = \text{BEGIN}, and the run ended with the error exit MEMERROR (register A =104= 104, the code of this error in the test). The location counter was 3501 after the increase.

Remarks

The simulator is protected against this case by the error exit and not by a test in line 010. A test in the control routine would cost time in every cycle.

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.