TAOCP 7.1.3 Exercise 200

In MMIX, register $0$ is the constant zero register, so its contents are $0$.

Section 7.1.3: Bitwise Tricks and Techniques

Exercise 200. [20] [20] Interpret the contents of register $3 after the following three MMIX instruc- tions have been executed: MOR $1,$0,#94; MXOR $2,$0,#94; SUBU $3,$1,$2.

Verified: yes
Solve time: 55s


Solution

In MMIX, register $0$ is the constant zero register, so its contents are $0$.

The instruction

$\text{MOR } $1,$0,#94$ computes bitwise OR of the contents of $$ 0$ and the immediate constant $#94$, hence $$1 \leftarrow 0 \mid #94 = #94.$ The instruction $\text{MXOR } $2,$0,#94$ computes bitwise XOR of $$0$ and $#94$, hence

$$2 \leftarrow 0 \oplus #94 = #94.$

The instruction

$\text{SUBU } $3,$1,$2$ performs unsigned subtraction modulo $2^{64}$, so

$$3 \leftarrow #94 - #94 = 0.$

Therefore the final contents of register $$3$ are

$\boxed{0}.$