From Esolang
Jump to navigation Jump to search
Paradigm(s) Stack-based
Designed by User:GUAqwq
Appeared in 2023
Computational class Turing complete
Major implementations Implemented
File extension(s) .ts_

Tetrastack is a stack-based esoteric programming language. Each stack has its own pop behavior. It's the 1st esolang of TS Series by User:GUAqwq


There are four stacks of integers. Stacks are referenced by numbers from 0 to 3.

Source code consists of hexadecimal digits. Each digit represents an instruction. The two upper bits represent the stack which an element will be popped from, while the two lower bits represent the stack which the element will be pushed to.

For example, BD7A corresponds to 23 31 13 22, which in interpreted as

  • Pop from stack 2 and push to stack 3
  • Pop from stack 3 and push to stack 1
  • Pop from stack 1 and push to stack 3
  • Pop from stack 2 and push to stack 2

Popping from stack 0 increments the value of the popped number (before pushing to the new stack). Popping from stack 1 decrements the value. Popping from stacks 2 or 3 does not change the value.

If you ever try to pop from a empty stack, it will crash down immediately.

Special cases

Instruction F (pop from 3; push to 3) is special. It pushes number 0 to stack 2.

A loop starts with an instruction that pops from stack 3 (and pushes to any stack except 3), and ends with instruction A (pop from 2; push to 2). When a number is popped from stack 3, if it is 0 then jump past the matching instruction A (the end of the loop). Otherwise execute the loop. When A is reached, jump to the matching loop start. Loops can be nested.

In summary, special instructions are A and all instructions that pop from stack 3.


The inputs/outputs correspond its ASCII. The end of the inputs is the top of stack0. (the end of the stack0 is a extra -1 The top of stack3 is the start of outputs.

Computational class

Tetrastack is Turing complete because any brainfuck program can be translated to Tetrastack using the following conversions:

Start of the program: F97F963D63AF94F95F8F803DF803DF803DF803DF803DF803DF803D007A7A7A7A7A7A7A16F833DD

End of the program: F9FC3FBAEC3FBAABDBA43D743A

< → 21595F833DD7A4FBFBAD7F94F8BFD7082AF8A
> → 40F833ED7A4094FBFBAD7F95F8BFD7082AF8A
+ → F832157CD7A8FBFBAD78F8A
- → F8317ED7A094FBFBAD71F8054A
. → 3F8FD7082A15497
[ → 17C
] → 17AF8


Cat program


Hello, World!