esolang

processor.txt

An instruction set written down in a text file, one character to an opcode.

Miles Poland, 2021 · Turing complete: with unbounded memory · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 4D4850

The idea

Miles Poland wrote processor.txt on 18 June 2021, after the RISC style of processors. The name has .txt in it because the first specification was a text file. Each instruction is one character, and the specification says a real chip would use the character's hex code as its opcode.

Read the story

There is DATA, a row of 1,024 cells under a pointer, and eight registers named a to h. There is no input at all, so a cat program is impossible. Only the first line of a file is read, which makes every other line a comment.

The machine

CharDoes
+ -Add or take 1
% _Shift the cell one bit left or right
! & ^NOT, AND and XOR, the last two with the selected register
, . / ; @ [ ] \Copy the cell into register a to h and select it
$ * ? : # { } |Copy register a to h into the cell, clearing it except for a
> <Move the pointer
~Print the cell
( )Jump back to the last ( when the cell is 0

A backquote does nothing. The loop is inverted. It repeats while the cell is 0 and ends once the cell is anything else.

Example

The specification prints its author's username, 4D4850, by counting up and down and runs it with the…

The specification prints its author's username, 4D4850, by counting up and down and runs it with the switch -a, which prints cells as characters. This implementation always does.

The shorter version builds each character from its bits. + sets the lowest bit, % shifts it along, and $ clears the cell by copying in register a, which is still 0.

Expected: 4D4850

A loop that prints eight letters. The count lives in register a. Each pass shifts a copy of it right three times, which stays 0 until the count reaches 8.

Expected: ABCDEFGH

Patterns it teaches

  • Turing tarpit: 29 one-character opcodes on bytes, with a loop that waits for a cell to stop being 0.
  • Encoding tricks: characters built bit by bit with an add and a shift.

Further

Also in Turing tarpits

Write your own in Run Convert a program from processor.txt

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: processor-txt.

Command line

shib run processor-txt -e '+%+%%+%%~$+%%%%+%%~$+%+%%+%%~$+%+%+%%%~$+%+%%+%%+~$+%+%%%%~'
shib manual processor-txt

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/processor-txt.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org