Hexadecimal Stacking Pseudo-Assembly Language

From Esolang
(Redirected from HSPAL)
Jump to navigation Jump to search

The Hexadecimal Stacking Pseudo-Assembly Language (HSPAL) is a programming language by User:SuperJedi224 in which a program is represented by a list of six-digit hexidecimal numbers seperated by line breaks (or not at all, the line breaks are optional and, in fact, all other whitespace is forbidden).

Data is stored as 16-bit unsigned integers in up to 256 unbounded-capacity stacks and a single register.

Control structure takes the form of simple conditionals (of exactly one command) and goto statements.

The specifications include a proof of Turing completeness.

Instructions

Instruction format is as:

ABXXYY

A is the instruction group
B is the instruction
All operations throw an exception and exit with status code FFFF / -1 if:

  • A stack is empty when popped
  • Two labels have the same ID
  • A label that doesn't exist gets jumped to

If the program finishes with no exit command and no exceptions, the program will exit with an exit code of 0000 / 0.
Opcode: AB

Instruction group 0: Program Control
Opcode Details
00 Make a label with ID XXYY
01 Goto label XXYY
02 Pop element from stack XX. Goto label specified by element popped.
03 Pop element from stack XX. If the element is nonzero, skip the next instruction.
04 Exit with the exit code of XXYY.
Instruction group 1: Input / Output
Opcode Details
10 Get user input as Unicode character, EOF = 0 and push onto stack XX
11 Get user input as number, EOF = 0 and push onto stack XX
12 Pop number off stack XX and output as number
13 Pop number off stack XX and output as character
14 Pop values off stack XX until empty, outputting each element as Unicode characters in the order popped. Do nothing if stack is empty.

Examples

The Hello, World! program:

200021
400000
200064
400000
20006C
400000
200072
400000
20006F
400000
200057
400000
200020
400000
20002C
400000
20006F
400000
20006C
400000
20006C
400000
200065
400000
200048
400000
140000

A (horribly slow) 16-bit Brainf*** interpreter

Translated from Daniel B Cristofani's Brainf*** self-interpreter. It can be found here. Input is program source followed by program input, seperated by an !. Technically non-standard, as it uses unsigned shorts while Brainf*** proper uses unsigned bytes.

Interpreters

The source for a java-based interpreter can be found here.

Additionally, there exists a Ruby interpreter which relaxes the syntactic restrictions mandated by the specification, but otherwise aims to hew very closely to the behavior defined therein.

A JavaScript online interpreter can be found here.

A Python interpreter can be found here.