Experiment · Computation
MTM-8
A 5-bit CPU that runs as a Turing machine.
Open MTM-8 (external) AutomataStudio (external) Source on GitHub (external)
MTM-8 is a small accumulator CPU. It isn’t hardware, and it isn’t an emulator in the usual sense. The whole CPU is a Turing machine with eight tapes, and AutomataStudio runs it. You write assembly, turn it into a tape, and watch the machine work through it.
Terms used here
- Turing machine
- A simple model of a computer. A head moves along a tape, reading and writing one symbol at a time, following a fixed table of rules.
- Tape
- The machine's memory: a row of cells, each holding one symbol. MTM-8 uses eight of them.
- Accumulator
- The register where arithmetic results are kept.
The machine
- Word size
- 5 bits, so numbers from 0 to 31
- Memory
- 32 words of RAM
- Registers
- A (accumulator) and X (index)
- Instructions
- 19
- Closest real chip
- A 5-bit MOS 6502
Instructions
| Group | Instructions |
|---|---|
| Arithmetic and logic | ADD SUB AND ORA EOR CMP |
| Memory and index | LDA STA TAX TXA STX LDX |
| Control flow | BCS SKP JMP JSR RTS JMPX HLT |
Run a program
- Write assembly in the editor. Labels,
;comments and the.accand.flagdirectives work. - Assemble it. You get a tape string.
- Download the
.automatonfile and open it in AutomataStudio. - Paste the tape and run it.
- Read the result. Tape 2 holds the accumulator and tape 5 holds RAM.
There is also a library of example programs you can load and change.
Limits
- Forward branches (
BCS,SKP) can jump at most 9 instructions. CMPtests “greater than or equal”, not equality.- Arithmetic wraps around at 32.
RTSwith an empty stack, or a jump past the last instruction, stops the machine without an error.
MTM-8 is released under the MIT licence.