ACIDIC
Two lines of characters, and all a program can do is move them from one line to the other.
iconmaster, 2010 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
iconmaster made ACIDIC in 2010. The opposite of a base is an acid, and as BASIC is an easy language, ACIDIC is a hard one. A program is two lines. The first is the Storage Stack, which holds the data, and the second is the Command Stack, which runs from right to left and starts again at the right end when it passes the left one.
Read the story
No command makes a new character. A program can only move characters between the two lines, and OUTPUT prints the whole Storage Stack, so the specification calls meaningful output nigh impossible. Taking a character out of the Command Stack also takes a command out of the program, so a program rewrites itself as it runs.
The machine
All 95 printable characters are commands. They are dealt out to the 19 commands in turn, from space to ~, so each command has five, and the code minus 32, modulo 19, picks it. A and B are two numbers that start at 0.
| Characters | Command | Does |
|---|---|---|
space 3 F Y l | PUSH | Move the leftmost stored character to the left end of the commands |
! 4 G Z m | POP | Move the command to its left to the front of storage |
" 5 H [ n | ROT | Rotate storage one place to the right |
# 6 I \ o | INC | Add 1 to A |
$ 7 J ] p | DEC | Take 1 from A |
% 8 K ^ q | JUMP | Go to command A, counted from the left |
& 9 L _ r | STKSZE | Set A to the size of storage |
' : M and the backtick s | JMPR | Jump A places to the left |
( ; N a t | PUSHR | Move stored character A to the left end of the commands |
) < O b u | POPR | Move command A to the front of storage |
* = P c v | OUTPUT | Print storage |
+ > Q d w | BRK | Halt |
, ? R e x | EXC | Swap A and B |
- @ S f y | INPUT | Set A to the next input byte, or -1 at the end |
. A T g z | RPLC | Replace this command with the stored character in the same column |
/ B U h { | ROTA | Rotate storage A places to the right |
0 C V i | | JMPZ | Jump to command A if B is 0 |
1 D W j } | JMPNZ | Jump to command A if B is not 0 |
2 E X k ~ | PLC | Set A to this command's place |
A command whose place is out of range does nothing. A run ends at BRK, or when no commands are left. This implementation runs the commands as the C# interpreter in the specification does.
Example
The first Hello World keeps the text in storage.
The first Hello World keeps the text in storage. The commands run from the right, so P prints it first and then w halts.
The better version starts with empty storage. Every ! is POP and moves the character to its left to the front of storage. They run from the right, so ! and d arrive first and H last, and the text ends up in order.
Four # set A to 4, and / turns storage four places to the right, which brings Hell round to the front.
Patterns it teaches
- Self-modifying code: moving a character to storage takes a command out of the program, and PUSH puts one in.
- Every text runs: every printable character is one of the 19 commands.
Further
See also
Also in Hostile
Write your own in Run Convert a program from ACIDIC
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: acidic.
Command line
shib run acidic -e 'Hello, world!
wP'shib manual acidicSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/acidic.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org