ESOPUNK

From Esolang
Jump to navigation Jump to search

ESOPUNK is a version of the EXA Programming language made by User:Blacksilver, which runs outside a network.

I/O

ESOPUNK makes stdin, stdout, and stderr available as the hardware registers #STDI, #STDO, and #STDE.

Reading from #STDI retuns a single character read from stdin, cast to a byte. If no data is available, the EXA will block.

Writing to #STDO or #STDE outputs a single byte, cast to a char, to stdout or stderr, respectively.


Commands

Against all rules and regulations, I'm using man-style formatting:

  • Bold: Type exactly as shown
  • Italic: Replace with appropriate argument.
Command Usage Equivalent (C)
Manipulation
COPY SRC DEST Copy the value from SRC [RI] to DEST [R] DEST = SRC;
ADDI A B DEST Take the sum of A [RI] and B [RI], and place it in DEST [R] DEST = A + B;
SUBI A B DEST Take the difference of A [RI] and B [RI], and place it in DEST [R] DEST = A - B;
MULI A B DEST Take the product of A [RI] and B [RI], and place it in DEST [R] DEST = A * B;
DIVI A B DEST Take the ratio of A [RI] and B [RI], and place it in DEST [R] DEST = A / B;
MODI A B DEST Take the mod of A [RI] and B [RI], and place it in DEST [R] DEST = A % B;
SWIZ A B DEST Swizzle A [RI] and B [RI], and place it in DEST [R]
Branching
MARK LABEL Mark the line with LABEL [L]. LABEL:
JUMP LABEL Unconditionally jump to LABEL. goto LABEL;
TJMP LABEL If the T register is truthy, jump to LABEL. Otherwise, noop. if(T){goto LABEL;}
FJMP LABEL If the T register is falsy, jump to LABEL. Otherwise, noop. if(!T){goto LABEL;}
Testing
TEST A = B Test if A [RI] and B [RI] are equal. Set the T register to 1 or 0 based on the result. T=(A==B?1:0);
TEST A > B Test if A [RI] is greater than B [RI]. Set the T register to 1 or 0 based on the result. T=(A>B?1:0);
TEST A < B Test if A [RI] is less than B [RI]. Set the T register to 1 or 0 based on the result. T=(A<B?1:0);
Lifecycle
REPL LABEL Create a copy of this EXA and jump to LABEL [L] in the copy. if(fork()==0){goto LABEL;}
HALT Terminate this EXA. exit(0);
KILL Kill a random EXA.
Communication
MODE Toggle the M register between local and global mode.
VOID M Read and discard a value from the M register.
TEST MRD If the M register is readable without blocking, set the T register to 1, else 0.

Examples

Truth-machine

COPY #STDI X
TEST X = 49 ; X == '1'
MARK L
COPY X #STDO
TJMP L
HALT

Cat

MARK LOOP
COPY #STDI X
TEST X > 0
FJMP DONE
COPY X #STDO
JUMP LOOP
MARK DONE
HALT

Computational Class

If EXAs are Turing-complete, then ESOPUNK is too.

The current pyESOPUNK implementation is probably a Linear bounded automaton, since neither files nor REPL have been implemented yet (giving you a whopping two memory locations), but the code size is unlimited. However, it *might* be Turing-complete, as the registers are not clamped as in the original language.

Interpreters