Deprecated.
This is an open source runtime for the minimalist machine language Do.
Do is a fictive machine language that reads, writes and jumps on a tape, working like a Turing machine. Read more about Do.
Let's assume you have the following Do code.
0 0 0 0 0 0 0 0 0 0 // read from 0
0 1 0 0 0 0 1 0 1 1 // write to 11
1 0 1 1 1 1 1 1 1 1 // jump to the end
To execute it, load the runtime and initialize a new instance.
var DoRuntime = require('do-runtime');
var r = Object.create(DoRuntime);
You have to pass the tape as an array of numbers. The second parameters is an optional options
object.
r.init([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 1, 0, 1, 1,
1, 0, 1, 1, 1, 1, 1, 1, 1, 1
], { // The following are the default values.
commandLength: 2,
addressLength: 8,
commands: ['read', 'write', 'goto', 'gotoIf'],
pointer: 0,
storage: 0
});
When you call run
, the Do runtime will execute the program until it jumps to the end of the tape (or beyond).
npm install do-runtime