I am teaching a course and have a tiny implementation of a counter-style machine that has the following instructions and two registers, r0 & r1
INC ri ; ri <- ri + 1 DEC ri ; ri <- r1 - 1 JNZ address ; if (r0 != 0) then jump to <address>. Else, skip. LDR ri, address ; load value at <address> into ri STR ri, address ; store the value in <ri> to <address>
What interesting programs can I make using this instruction set using no more than 16 instructions (the range of my address space).
So far, the best I have is "check if memory contains an odd value in the range 0-7"
Also, does it help if I add the following instruction:
JLT address ; if (r0 < 0) then jump to <address>. Else, skip.