Hanoi Love

From Esolang
Jump to navigation Jump to search

Hanoi Love is a minimal stack based language created by Jeffry Johnston, April 30, 2001. Its name was inspired by the Towers of Hanoi game, while the language itself was inspired by Spaz and brainfuck.

Command Short Name Description
. nxtstk next stack: selects next stack in order (A,B,C,D). loops back to A from D.
' cpyreg copy register: copies byte in register and pushes it to the stack: unless stack D, then push location pointer -1
, pfsmir pop from stack move into register: unless stack D, then pop & goto location previously pushed location
; pfsatr pop from stack add to register: unless stack D, then pop location and noop
` pfssfr pop from stack sub from register: unless stack D, then pop location and noop
' iomode io mode prefix: next instruction will pop from stdin or push to stdout instead of a stack.
: sifzer skip if zero: if the register is zero, skip instructions until the ! instruction is reached.
] eskhlt end skip/halt: if matching a :, end skip. if not matching a :, halt.

All characters other than .',;`":! should be considered comments and ignored.


There are 4 stacks and one register. A, B, C, D, REG.

Stack A is the initial stack. It pops a 1 if empty, holds 8bit values, and has boundless memory (limited only by physical memory)

Both Stack B and C pop a 0 if empty, hold 8bit values, and have boundless memory (limited only by physical memory)

Stack D is for storing the location of instructions. When a push operation is performed here, the previous instruction location (current location minus one) is pushed onto the stack. When a pop operation is performed the new instruction location is popped from the stack. If a ";" or "`" instruction is performed on this stack then the instruction location is popped, but no further action is taken (this is useful for breaking out of loops).

The register holds one 8 bit value, used for swapping between stacks. It is initalized to 0.

The original implementation does not specify EOL behavior or wrapping behavior.

BF to HL

Any brainfuck program can theoretically be run in Hanoi Love using a simple translation table. The original implementation provides this:

Brainfuck Hanoi Love
> ..,...'...
< .,.'..
+ ,.;'...
- .,...`.'...
. .,'"'...
, .,",'...
[ ...'..,'...:
] ...,!...;.

Cat program example


Hello world example


External resources