Varsig
The whole program runs again and again. What one run trips, only the next run sees.
Zzo38, 2008 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Zzo38 made Varsig in 2008 as a variant of SIG. There are no jumps. The program always runs from top to bottom and then starts over, until EXIT. Control comes from signals. TRIP n arms signal n for the next run only, and a block SIG n ... TERM runs in that next run if the signal was armed. The 26 variables A to Z cannot be set at all; each one that is read in a run counts one higher in the next.
The machine
| Command | Does |
|---|---|
SIG n ... TERM | Run the block if signal n was tripped in the run before |
TRIP n RESET n | Trip signal n for the next run, or undo that |
PRY CRAM | Push an input byte, or nothing at the end; pop and print |
EXIT | Stop |
GROW SHRINK | Add to or take from the cell a number, or a popped value |
SHOVE YANK | Push the cell or a number; pop into the cell |
CLONE BURN PURGE | Copy the top; drop it; clear the cell |
PUSH PULL FLIP | Move along the tape; turn the tape over |
MEASURE n | Keep n bits of every value, 8 at the start |
LESS MORE GOOD EVIL | Guard one command on the cell against the top of the stack |
CLEAN DIRTY | Guard one command on an empty or a full stack |
Every command also has a one-character shortcut. The tape has two sides, and on the back side PUSH and PULL move the other way.
Example
The copy from the specification.
The copy from the specification. Each run reads a byte, exits when there is none, and prints it.
A loop with a variable. A is read in every run, so it is 0, 1, 2 and 3 in the first four runs. Each run puts A on the tape, exits when it equals 3, and otherwise prints the letter 65 + A.
The specification says PUSH FLIP PULL FLIP leaves the pointer two cells ahead, and PULL 2 brings it back to the B. A signal tripped in a run opens its block only in the next one.
The program that writes its input backwards, in shortcut symbols. It marks its data with 321, which no 8-bit byte can equal, after raising the measure to 9 bits. Run by the rules, a 321 that the first block leaves at the bottom of the stack comes out last. CRAM prints the low 8 bits, so it shows as an A.
Patterns it teaches
- Stack machines: a stack beside the tape, with every jump replaced by the next run.
Further
See also
Cell-based
Stack-based
Write your own in Run Convert a program from Varsig
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: varsig.
Command line
shib run varsig -e 'PRY
CLEAN EXIT
CRAM' --input 'hello'shib manual varsigSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/varsig.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org