esolang

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

Expected: Hello, world!

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

InstructionDoes
a12 d12 h12 m12Register 1 becomes 1 + 2, 1 / 2, 1 mod 2 or 1 × 2
n12 o12 x12And, or, xor
e12 g12Copy 2 into 1; swap them
i1 c1 z1Add 1, take 1 away, set 0
b1255 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 tSkip as many instructions as 1 holds; end
u1 p1 q1 k1Push, pop, enqueue, dequeue
|< |> |^1 |v1Move the tape; write 1 to it or read it into 1
*12 &12Write 1 to memory address 2, or read it into 1
r1 w1 !1Read 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.

Expected: cat

Arithmetic goes through registers, and ! prints a number. The loop counts register 0 down from 5, printing as it goes.

Expected: 42
Expected: 54321

Patterns it teaches

Further

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 ursl

Source

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