Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Last active August 19, 2021 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derhuerst/3e98c06d4251f7207870 to your computer and use it in GitHub Desktop.
Save derhuerst/3e98c06d4251f7207870 to your computer and use it in GitHub Desktop.
An introduction to Do, a minimalist machine language.

Do – A minimalist machine language

Do is a fictive machine language that reads, writes and jumps on a tape, working like a Turing machine.

A Do programm is a particular serial alignment of 0 and 1 bits, stored on a so-called tape. These values are grouped into sections called buts, each consisting of 2 command bits and 8 address bits. The address part of a but is the binary representaion of a position on the tape. Additionally, a Do machine has single bit storage, comparable to a register of a CPU; The Do programm can read into the storage and write from it onto the tape.

Do provides the following 4 commands:

command address effect
0 0 0 0 0 0 1 0 1 0 Read the bit at position 10 from the tape into the storage.
0 1 0 0 0 0 1 0 0 1 Write the bit from the storage to position 9 on the tape.
1 0 0 0 0 0 0 1 1 1 Jump to position 7 on the tape.
1 1 0 0 0 0 0 0 0 0 Jump to position 0 if the content of the storage is 1.

Do code can be executed by the Do runtime, an open-source runtime written in JavaScript. The execution will terminate when the program jumps to the end of the tape (or beyond).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment