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
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
| R1 | R2 | Does |
|---|---|---|
i d | k e | Increment, decrement |
o a | p b | Print as a number, print as ASCII |
n z | q y | Read a number, set to 0 |
1 | 2 | Copy into the other register |
s f m | u g r | Sum, R1 minus R2, product |
l < > | h , . | Square, shift left, shift right |
^ | & | 6 \ 7 | Xor, 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.
| Block | Does |
|---|---|
j XX nnnn | Run the next nnnn characters once if R1 XX R2 |
w XX nnnn | Repeat them while R1 XX R2 |
@ nnnn | Repeat them for ever |
: nnnn name | Declare a subroutine with a four-letter name |
; name | Call 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.
A count to five. Register two holds 5, and w<<0002 repeats io while register one is less.
Patterns it teaches
- Counter machines: two registers, increment, decrement and a loop that compares them.
Further
See also
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 drolSource
- 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