8-tape accumulator CPU · mtm-cpu.automaton

MTM–8 Assembler

Word
5 bit
RAM
32 words
Opcodes
19
Registers
A, X

Assembly

→
1
Ready.
←

Tape

 

Run it

The CPU is a Turing machine; AutomataStudio simulates it.
  1. Download the automaton file and open AutomataStudio.
  2. Drag the file into AutomataStudio to load the machine.
  3. Write a program above, or load one from Programs below, then Copy the tape.
  4. In AutomataStudio, paste the tape into Simulate String and press Play.
  5. When it halts, read the result off the tapes: tape 2 is the accumulator, tape 5 is RAM.

Tape strip

One cell per instruction. Gold underline marks a control transfer; green edge marks a jump target.

Programs

Load one, then edit it.

Instruction set

Arithmetic & logic — 5-bit immediate
OpMnemonicEffect
AADD nA = A + n
SSUB nA = A − n
NAND nA = A & n
OORA nA = A | n
XEOR nA = A ^ n
CCMP nflag set if A ≥ n
Memory & index
OpMnemonicEffect
LLDA addrA = RAM[addr]
TSTA addrRAM[addr] = A
UTAXX = A
VTXAA = X
ESTXRAM[X] = A
DLDXA = RAM[X]
Control flow
OpMnemonicEffect
JBCS dskip d ahead if flag set
MSKP dskip d ahead, always
PJMP ngo to instruction n
KJSR ncall instruction n
RRTSreturn
WJMPXgo to instruction X
!HLThalt — the accepting state
Reading a tape

A program is ^flag#seed# then instructions, ending !. flag is f or g; seed is the 5-bit starting accumulator. Every operand carries a trailing #.

Directives: .acc n, .flag f|g. ; starts a comment, label: marks an instruction.

What will catch you