ZeroStack2D

From Esolang
(Redirected from Esolang:ZeroStack2D)
Jump to navigation Jump to search

ZeroStack2D is a stack-based, 2D grid esoteric programming language, designed to be Turing-complete. It draws inspiration from Befunge and Brainfuck, combining 2D instruction pointer movement with a minimal stack-based execution model.

Overview

Description

ZeroStack2D operates on a 2D grid of characters, where an instruction pointer (IP) moves across the grid, executing commands. The language's core is a single stack, which is used for all data storage and manipulation.

Truth Machine

v >v
  + 
  ! 
  . 
>~|<
  .
  @

Instructions

Command Description
> Set IP direction to right
< Set IP direction to left
^ Set IP direction to up
v Set IP direction to down
0/! Push 0 onto the stack
+ Pop a value, increment, push the result
- Pop a value, decrement, push the result
: Duplicate the top stack value
\ Swap the top two stack values
$ Pop and discard the top stack value
? Read a character from input, push its ASCII value
~ Read an integer from input, push it
. Pop a value and print it as a number
, Pop a value and print it as a character
| If the top of stack is non-zero, set direction up, else down
_ If the top of stack is non-zero, set direction right, else left
@ Terminate the program

Turing completeness

ZeroStack2D is Turing-complete, as it can simulate a Minsky machine, which is known to be Turing-complete. This is achieved by using the stack to represent counters and the conditional jump instructions to control the flow.

Implementations

Code is on GitHub:https://github.com/huyuenshen/ZeroStack2D/