Stackmill
Jump to navigation
Jump to search
Stackmill is an esoteric programming language created by User:Asiekierka on 25th December 2010.
Commands
00xx - input value xx (in binary) to stack 0100 - NAND the two top values on stack (8-bit) 0101 - pop value on stack 0110 - shift entire stack up 0111 - shift entire stack down 1000..1001 - execute code inbetween while the topmost stack value is nonzero 1010 - output value (as number or char, depends on implementation this time) 1011 - input value (as char) 11xx - perform an operation on 2 topmost values: when xx is: 00 - + 01 - - 10 - * 11 - / for example, 1101 (subtraction) stack: 3 -> 1 2 0 0
The bitwidth is up to the interpreter (default: 32 bits signed). The input/output method is also up to the interpreter (asiekierka's outputs as numbers and inputs as chars)
Examples
Fibonacci
0010 1010 0011 1010 // initialize and output 2 and 3 1000 // start loop, first run is 2 and 3 0000 0000 0110 0110 1000 0001 1101 0000 1101 0111 0001 1100 0111 0001 1100 0110 0110 1001 0101 0110 0110 // duplicate the bigger value 1100 1010 // add them up 1001 // end loop, 3 and 5 should be on stack on first run
Turing-completeness
A sub-Turing complete variant of brainfuck with a fixed-length tape can be translated to Stackmill. First, push n elements, where n is the size of the tape. Then:
< 0110 > 0111 [ 1000 ] 1001 + 0001 1100 - 0001 1101 0000 1101 , 1011 . 1010
Bitwise Cyclic Tag can be implemented in Stackmill, though, using these instructions:
0 pop the topmost stack value 1 if topmost stack value is 1, push the next input value (0 or 1) on stack then shift up loop and exit condition: push a non-BCT value (for example, 3), then shift up. if you get the same value, the stack is empty. halt. otherwise shift down and pop value, continue execution.