esolang

Hexadecimal Stacking Pseudo-Assembly Language

Every instruction is six hex digits. There are 256 stacks and one register.

SuperJedi224, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Ho!

The idea

SuperJedi224 made HSPAL in 2015. A program is a list of numbers like 200048. The first two digits are the opcode, the next two name one of 256 stacks, and the last four together form a 16-bit number. Control flow is labels, a goto, and one instruction that skips the next one.

Read the story

TIO runs a fixed Ruby interpreter by Conor O'Brien. It allows comments after ; and ignores any other character that is not a hex digit.

The machine

OpcodeDoes
00 01 02Set label XXYY; jump to it; jump to a label popped from stack XX
03 04Pop and skip the next instruction if above 0; stop
10 11Push an input character; push a number from a line
12 13 14Print a popped number; a popped character; the whole stack, top first
20 40 41 42 43Register = XXYY; push it and clear it; pop into it; copy the top; the stack size
21 to 25Pop two, push top + - * / ** the one below
30 31 32Pop two, push top == > < the one below onto stack YY

Every value is clamped to 0..65535 as it is pushed, so 3 - 5 gives 0. A label exists only once its 00 has run. Two quirks of the Ruby stay. 33 to 35 were meant as bitwise tests but always push 1, since every Ruby number counts as true, and 11 reads its line from the program file itself.

Example

The first pushes three characters and prints the stack top first.
Expected: 42
Expected: cat

The first pushes three characters and prints the stack top first. The cat sets label 0, reads a character, copies it to stack 1, and stops when that copy is 0, which is what the end of the input gives.

Further

Ideas it shows

Stack-based

Write your own in Run Convert a program from Hexadecimal Stacking Pseudo-Assembly Language

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run hspal -e '200006 400000 200007 400000 230000 120000'
shib manual hspal

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/hspal.js

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

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