Reputation: 8585
Im reading the Knuth's book TAOCP. And im just learning a simple math operations with registers. And there is an example of subtraction operation:
rA before: - | 1234 | 0| 0| 9
Cell 1000: - | 2000 | 150| 0
SUB 1000
rA after: + | 766 | 149 | ?
i understand that -1234-(-2000) = 766 but how (0 | 0) - 150 = 149 ??
and why 9 - 0 = ?
These are "packed" words. And maybe i need to read more about them. Or can anyone explain ?
Upvotes: 4
Views: 332
Reputation: 27334
I believe the logic goes like this:
rA
contains the value - 1234 00 00 09
.M
contains the value - 2000 0150 00
.M
from rA
using plain decimal arithmetic gives 766,014,991, or + 0766 0149 91
.Alternatively,
rA
contains the value - 04D2 00 00 09
.M
contains the value - 07D0 0096 00
.M
from rA
using plain hexadecimal arithmetic gives 0x2FE0095F7, or + 02FE 0095 F7
, or in decimal, + 0766 0149 247
[sic].So, without knowing the binary/decimalness of this particular MIX machine, we can't say for certain what the low-order byte of the result will be. It is guaranteed to be the single-byte representation of -9
, but whether this is 91
decimal or 0xF7
binary is unknowable.
I don't have TAOCP in front of me right now to check, but I believe this logic is a pretty good explanation of the ?
that was puzzling you.
Upvotes: 7