I have been reading the Art of Computer Programming by Donald Knuth Volume 1. Now I finished the first part where all the mathematics were explained and it was quite a pleasure. Unfortunately, on p. 121 he starts explaining this fictional machine language called MIX
based on real machine languages in which he will subsequently explain all the algorithms and Mr. Knuth is losing me completely.
I hope there is someone here that 'speaks' a bit of MIX
and can help me understand it. Specifically, he lost me where he starts explaining different operations and showing examples (p. 125 onward).
Knuth uses this "instruction format" with the following form:
He also explains what the different bytes mean:
So the right byte is the operation to be performed (e.g., LDA
"load register A"). F byte is a modification of the operation code with field specification (L:R) with 8L + R (e.g., C=8 and F=11 yields "load A register with the (1:3) field). Then +/- AA is the address and I the index specification to modify an address.
Well this makes some sort of sense to me. But then Knuth comes with some examples. The first I do understand except for a few bits, but I cannot wrap my head around the last three of the second example and nothing at all from the more difficult operations in example 3 below.
Here is the first example:
LDA 2000
just loads the full word and we see it completely in register A rA
. The second one LDA 2000(1:5)
loads everything from the second bit (index 1 ) till the end (index 5) and that is why everything except the plus sign is loaded. And the third with LDA 2000(3:5)
just loads everything from the third byte till the last. Also LDA 2000(0:3)
(fourth example) kind of makes sense. -803 should be copied and the - is taken and the 80 and 3 are placed at the end.
So far so good, in number5, if we follow the same logic, LDA2000(4:4)
it only transferring the fourth byte. Which it indeed did to the last position. But then, in LDA 2000(1:1)
only the first byte (the sign) should be copied. This is weird. Why is the first value a + instead of a - (I expected only the - to be copied). and why are the other values all 0 and the last a question mark?
Then he gives the second example with the operation STA
(store A):
Again, STA 2000
, STA 2000(1:5)
and STA 2000(5:5)
make sense with the same logic. However, then Knuth does STA 2000(2:2)
. You would expect to have the second byte copied which equals 7 in register A. However somehow someway we end up with - 1 0 3 4 5
. I have been looking at these for hours and have no clue how this, or the two example that follow this one (STA 2000(2:3)
and STA 2000(0:1)
) can result in the contents of the location as displayed.
I hope someone here can shine his light on these last three.
Furthermore, I also have big trouble with the page where he explains the operations ADD
, SUB
, MUL
, and DIV
. The third example, see
This third example is my final goal to understand and right now it makes absolutely zero sense at all. This is very frustrating since I do want to continue with his algorithms but if I don't understand MIX
I will not be able to understand the rest!
I hope someone out here has had a course on MIX
or sees something that I do not see and is willing to share his or her knowledge and insights!