Stack-gpt

From Esolang
Jump to navigation Jump to search

Stack-gpt is an esoteric programming language (esolang) created by ChatGPT 4o mini. It operates primarily on a stack structure, allowing manipulation of data through commands that push, pop, and perform operations on values.

Commands

Below are the primary commands of the Stack-gpt language:

Stack-gpt is not turing complate please dont waste your time

Commands Table
Command Description
+ Pops two numbers from the stack, adds them, and pushes the result.
- Pops two numbers, subtracts the second from the first, and pushes the result.
* Pops two numbers, multiplies them, and pushes the result.
/ Pops two numbers, divides the first by the second, and pushes the result.
% Pops two numbers, computes the modulus, and pushes the result.
^ Pops two numbers, performs a bitwise XOR, and pushes the result.
& Pops two numbers, performs a bitwise AND, and pushes the result.
Pops two numbers, performs a bitwise OR, and pushes the result.
push Pushes a given character, string, or number (int/float) onto the stack.
pop Pops the top value from the stack without further action.
dupe Duplicates the top item on the stack.
die Terminates the program.
print Prints the number on top of the stack with a newline.
printc Prints the ASCII character corresponding to the number on top of the stack. No newline is added.
len Pushes the length of the stack (plus 1) onto the stack.
negative If the top number is negative, pops it and pushes 0; otherwise, leaves the number unchanged.
input Takes a string input from the user and pushes each character (as ASCII values) onto the stack.
if number label If the top number of the stack equals the given number, jumps to the specified label.
goto label Jumps to the specified label.

Examples

truth machine

push ">0ro1"
start:
len
if 1 truthmachine
pop 
printc
goto start
truthmachine:
input
if 49 lep
push 0
print
die
lep:
push 49
printc
goto lep

hello world

push "!dlrow"
push 32 
push "olleh"
start:
len
if 1 end
pop 
printc
goto start
end:
die

yes this page generated by chatgpt

interpreter: https://github.com/serpentis64/stack-gpt/blob/main/main.py