Generic assembly language for implementing esolangs
Python 100.00%
super_stack's Introduction
Super Stack Assembly Intepreter
A minimal stack based assembly language. Super Stack has similar instructions to the whitespace language and can be used to assemble whitespace programs.
Hello World
.main:push0push"Hello World!".print: copyjz .end putcharjmp .print.end:pop halt
Push program position to the call stack and jump to label
RET
Return to position at the top of the call stack
HALT
Halt
Arithmetic operations
Instruction
Meaning
ADD
Add
SUB
Subtract
MUL
Multiply
DIV
Divide
push7 # [7]push1 # [7,1]sub # [-6]halt
IO Instructions
Instruction
Meaning
READ
Read integer from console (stores in heap)
PUTS
Write integer to console
READCHAR
Read character from input (file or console) [stores in heap]
PUTCHAR
Write character to output (file or console)
OPENF
Open file
CLOSEF
Close file
DUMP
Dump memory
push1 # Open file for writtingopenf "a.txt"push117putchar # Write character 'A' to a.txtclosefpush0 # Open file for readingopenf "a.txt"push100copy # [100,100]readchar # {100: 117} [100]closefaccess # [117]putchar # Ahalt
.main:push100.loop: # Print number of bottles copy putspush0push" bottles of beer on the wall,"call .print copy putspush0push10push" bottles of beer"call .print # Subtract 1 bottle copypush1 swapsubpush0push"Take one down and pass it around"call .print copy putspush0push10push10push" bottles of beer on the wall."call .print # Check for end of loop copyjz .endjmp .loop.print: copy putcharjnz .printret.end:pop halt
Truth machine
.main:push63 putcharpush100 readcharpush100 haccess.loop: copypush48subjnz .loop halt