I'm learning MMIX so I tried making a simple program to add one to itself and print the result. Unfortunately it doesn't print anything. Here is my program:
n IS $4
y IS $3
t IS $255
LOC #100
Main SET n,1 %let n = 1
ADD y,n,1 %add 1 to n and store the result in y
LDA t,y
TRAP 0,Fputs,StdOut
TRAP 0,Halt,0
What am I doing wrong?
The link in Robert's own response is broken. Also the explanation is unsatisfactory.
The main issue is there is no
printf
in MMIX assembly. So you can't just print a number directly. It needs to be converted to a string forFputs
to work.Once you know this the solution is easy. The challenge is to code it in MMIX. The program below handles one unsigned number.