esolang

AlphaStack

Only the 26 lower case letters count, and each one is a value, an instruction and a register.

Glax, 2026 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 26 known programs · Test method

Run it

Expected: f

The idea

Glax made AlphaStack in 2026. As a value a letter is a number, a is 0 and z is 25, and all arithmetic wraps at 26. As an instruction it does one thing to a value stack or to a procedure stack. And every letter names a register, and some of these change how their own instruction works. The p register picks how p prints, and the a register picks what a computes.

Read the story

A run starts in literal mode, where every letter is pushed. l switches to instructions and back, so l itself can never be pushed. Programs make one with arithmetic instead, kb and then a, which adds 10 and 1.

There is no syntax for a procedure. d pops the letters between two marks off the value stack and pushes them on the procedure stack, in the order they come off. That is why the specification writes its procedures backwards.

The machine

LetterDoes
aPop two numbers and add them; the a register can make it subtract, multiply, divide, take the modulo or compare
bBreak out of the loop
cCopy the item n places down
dPop a mark and every letter down to the next mark into a procedure
eRun the procedure that the e register counts from the bottom
fFlip the top n items
g sGet or set a register
hHalt
iPop a value and a procedure, and run it when the value is not a
kCopy the top procedure
lSwitch between literal and instruction mode
mPush the m register
nPush the number of items on the stack
oReplace one letter with another, down to a mark
pPrint a letter, as lower case, upper case, digits, punctuation or control codes
rPop a count and a procedure and run it that many times, or for ever on a
tRead a character
uPop down to a mark
wRotate the top n items
xRun the top procedure
yEnd the current procedure

j, q, v and z do nothing, and every character that is not a lower case letter is a comment. With the i register set to n, i becomes a chain of n conditions and n + 1 procedures. With the n register set, the numbers that a, i and n work on take more than one letter each.

Example

c is 2 and d is 3, so a leaves f.

c is 2 and d is 3, so a leaves f.

The Hello World pushes its letters, prints H in upper case mode, turns every j into an l and then switches print modes for the space, the W and the !. In digit mode w prints a space.

Expected: Hello World!

A loop that prints the stack until it reaches z. The procedure compares a copy of the top with z, and on a match it runs h.

Expected: printingthestack

t reads a character as a letter. a is false, so the procedure that pushes a does not run and the z under it is printed.

Expected: z

A 99 bottles of beer program counts down from 99 to no more bottles.

Patterns it teaches

  • Stack machines, with two stacks, one for values and one for procedures.
  • Code as data, as a procedure is made from letters that were data a moment before.

Further

Stack-based

Write your own in Run Convert a program from AlphaStack

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: alphastack.

Command line

shib run alphastack -e 'cdlap'
shib manual alphastack

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/alphastack.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org