esolang

DROL

Two registers, a set of letters for each, and loops that say up front how long they are.

Bradley Sadowsky, 2016 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

Bradley Sadowsky made DROL, the Double Register Optimization Language, in 2016. His compiler, written in Python 2.7, turns it into C. All work happens in two registers, as in Deadfish, and each register has its own letter for every command. i increments register one and k increments register two; a and b print them as ASCII.

Read the story

Loops and subroutines have no brackets. Each starts with a header that gives, in four digits, how many characters it spans. The specification says the optimization in the name just sounded nice, as the language is far from optimized.

The machine

R1R2Does
i dk eIncrement, decrement
o ap bPrint as a number, print as ASCII
n zq yRead a number, set to 0
12Copy into the other register
s f mu g rSum, R1 minus R2, product
l < >h , .Square, shift left, shift right
^ | &6 \ 7Xor, or, and with the other register

~ flips the bits of register one and ` those of register two. 0 does nothing, x exits, ! prints a line feed, * swaps the registers and { } hold a comment.

BlockDoes
j XX nnnnRun the next nnnn characters once if R1 XX R2
w XX nnnnRepeat them while R1 XX R2
@ nnnnRepeat them for ever
: nnnn nameDeclare a subroutine with a four-letter name
; nameCall it

XX is ==, !=, >=, <=, >> for greater or << for less. The extended forms " ' # ( ) take eight digits and eight-letter names. The counts skip comments and whitespace, so the truth machine reads the same spread over lines as packed into one. Registers are 32-bit C ints.

Example

The shorter Hello World builds each letter from a few increments and left shifts.

The shorter Hello World builds each letter from a few increments and left shifts. It keeps 111, the o, in register two with * for later.

The truth machine. j==0002 runs ox only when the input equals register two, which is still 0. On 1 the second test passes and @0001 prints 1 for ever.

Expected: 0

A count to five. Register two holds 5, and w<<0002 repeats io while register one is less.

Expected: 12345

Patterns it teaches

  • Counter machines: two registers, increment, decrement and a loop that compares them.

Further

Also in Turing tarpits

Write your own in Run Convert a program from DROL

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: drol.

Command line

shib run drol -e 'nj==0002oxkj==0006@0001o' --input '0'
shib manual drol

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/drol.js

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

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