Exercise · Volume 1 · 1.3.1-6
Exercise 1.3.1-6
not stated yet in Lean solution written
| Rating | 10 |
|---|---|
| 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 result of five load instructions on a given word and state which ones are undefined.
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
Write the word as sign, byte 1, byte 2, bytes 3 and 4 (the two-byte number 200), byte 5.
Hint 2
A partial field is shifted to the right of the register. The sign is used only when the field starts at . Otherwise the sign is understood.
Hint 3
An index register has only two bytes and a sign.
Solution
Show the solution
Let and . Then bytes 3 and 4 are and . For they are and , and for they are and . The word is .
(a) LDAN 3000 loads the whole word with the sign reversed, so (written ).
(b) LD2N 3000(3:4) takes bytes 3 and 4 with the sign and then negates. So . This fits in two bytes.
(c) LDX 3000(1:3) takes bytes 1 to 3, that is , and moves them to the right: . The sign is .
(d) LD6 3000 is undefined. It would put the whole word in an index register, which has room for two bytes. Here bytes 1 to 3 are not zero.
(e) LDXN 3000(0:0) takes the sign alone, which is with the magnitude , and negates it. So .
Check
python3: with the value , and with it is . In both cases . In (c) the last byte is for and for .
Remarks
Case (d) is the usual reason why one loads an index register from a field such as and not from the whole word.
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.