The rmachine software is a simulation tool for register machines.
One of the standout features of rmachine is that the machine or RAM is equal in computational power to Turing machines. Essentially, this means that the machine has theoretically unlimited memory, although this will be limited in practice by your computer's memory. The registers or memory cells within the machine can store integers >=0 of any length.
For example, if the 5th register contains the number 42, it would be written as c(5)=42. It's worth noting that c(0) is also known as "assembler" and plays an essential role that will become apparent later. Moreover, the RAM has a program counter b, which is set to 1 initially and represents the next line of instructions to be executed.
The structure of a program typically resembles the following format:
# Comments go here
# More comments
INPUT 4 6 8 9
(Instructions go here)
END
As you can see, the "INPUT" line should immediately follow the comments. Any user input will be placed inside c(1), c(2), etc. For instance, in the above example, c(1)=4, c(2)=6, c(3)=8, c(4)=9.
Now that you have an idea of how the rmachine software works, here is a list of instructions that can be utilized:
-- LOAD i c(0):=c(i), b:=b+1
-- CLOAD i c(0):=i, b:=b+1
-- INDLOAD i c(0):=c(c(i)), b:=b+1
-- STORE i c(i):=c(0), b:=b+1
-- INDSTORE i c(c(i)):=c(0), b:=b+1
-- ADD i c(0):=c(0)+c(i), b:=b+1
-- CADD i c(0):=c(0)+i, b:=b+1
-- INDADD i c(0):=c(0)+c(c(i)), b:=b+1
-- SUB i c(0): = max(c(0) - c(i),0), b:=b+1
-- CSUB i c(0): = max(c(0) - i,0), b:=b+1
-- INDSUB i c(0): = max(c(0) - c(c(i)),0), b:=b+1
-- MUL i c(0):=c(0)*c(i), b:=b+1
-- CMUL i c(0):=c(0)*i, b:=b+1
-- INDMUL i c(0):=c(0)*c(c(i)), b:=b+1
-- DIV i c(0):=c(0)/c(i), b:=b+1 Note: The decimals will be cut off
-- CDIV i c(0):=c(0)/i, b:=b+1 Note: The decimals will be cut off
-- INDDIV i c(
Version 0.12: N/A