Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

derhuerst/do-runtime

Repository files navigation

do-runtime

Deprecated.

No Maintenance Intended npm version bower version MIT-licensed

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.

Example

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).

Install

npm install do-runtime