URSL
Ten registers, a stack, a queue, a tape and a memory array, all worked by one-letter instructions.
David.werecat, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
David.werecat made URSL in 2012. It reads like an assembly language cut down to the bone. Every mnemonic is one letter and every operand is one digit naming a register, so a12 adds register 2 to register 1 and w0 writes register 0 as a character. A constant is written with v, which takes decimal digits up to a closing -.
Read the story
Around the ten registers sit four more stores, a stack, a queue, a tape and a memory array, and values move between all of them. Blocks end with their own closer. ? ends an if, / ends a loop and a second \ ends an infinite loop. Spaces, line breaks and ; may go anywhere and mean nothing.
The machine
| Instruction | Does |
|---|---|
a12 d12 h12 m12 | Register 1 becomes 1 + 2, 1 / 2, 1 mod 2 or 1 × 2 |
n12 o12 x12 | And, or, xor |
e12 g12 | Copy 2 into 1; swap them |
i1 c1 z1 | Add 1, take 1 away, set 0 |
b1 | 255 if 1 is 128 or more, else 0 |
v172- | Set register 1 to 72 |
fo1 ... ? fz1 ... ? | Run the block if 1 is not 0, or if it is 0 |
lo1 ... / lz1 ... / | Loop while 1 is not 0, or while it is 0 |
\ ... \ @ | Loop for ever; break out |
j1 t | Skip as many instructions as 1 holds; end |
u1 p1 q1 k1 | Push, pop, enqueue, dequeue |
|< |> |^1 |v1 | Move the tape; write 1 to it or read it into 1 |
*12 &12 | Write 1 to memory address 2, or read it into 1 |
r1 w1 !1 | Read a character; write it as a character or as a number |
The specification also has # to beep, ~ to clear the console, $ to sleep a second and % to throw an error. This implementation ignores the first three.
Example
The Hello World sets register 0 to each character code in turn and writes it.
The Hello World sets register 0 to each character code in turn and writes it.
The cat reads a character into register 0 and writes it, for ever. The end of the input ends the run.
Arithmetic goes through registers, and ! prints a number. The loop counts register 0 down from 5, printing as it goes.
Patterns it teaches
- Counter machines: registers that count up and down, tested for 0.
- Stack machines: one of four stores beside the registers.
Further
See also
Queue-based
Cell-based
Write your own in Run Convert a program from URSL
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ursl.
Command line
shib run ursl -e '\r0w0\' --input 'cat'shib manual urslSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ursl.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org