esolang

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

Expected: hello

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

CommandDoes
SIG n ... TERMRun the block if signal n was tripped in the run before
TRIP n RESET nTrip signal n for the next run, or undo that
PRY CRAMPush an input byte, or nothing at the end; pop and print
EXITStop
GROW SHRINKAdd to or take from the cell a number, or a popped value
SHOVE YANKPush the cell or a number; pop into the cell
CLONE BURN PURGECopy the top; drop it; clear the cell
PUSH PULL FLIPMove along the tape; turn the tape over
MEASURE nKeep n bits of every value, 8 at the start
LESS MORE GOOD EVILGuard one command on the cell against the top of the stack
CLEAN DIRTYGuard 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.

Expected: ABC

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.

Expected: B
Expected: H

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.

Expected: cbaA

Patterns it teaches

  • Stack machines: a stack beside the tape, with every jump replaced by the next run.

Further

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 varsig

Source

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