Advanced Subleq Assembler
This Subleq assembler uses a custom assembly-like language, called Sublang, that is assembled to Subleq
Features
- Interpreter and debugger
- Macros
- Syntax sugar for common constructs
- In depth assembler feedback
- Optional typing system
- Fully fledged standard lib including functions and high level control flow constructs like If or While
- Fine grained control
What is Subleq?
Subleq or SUBtract and jump if Less than or EQual to zero is an assembly language that has only the SUBLEQ instruction. It has three operands: A, B, C.
The value at memory address A is subtracted from the value at address B. If the resulting number is less than or equal to zero, a jump takes place to address C. Otherwise the next instruction is executed.
Since there is only one instruction, the assembly does not contain opcodes.
So:
SUBLEQ 1 2 3
would just be
1 2 3
A very basic subleq interpreter written in Python would look as follows
=
=
=
= -
=
=
+= 3
Most subleq implementations, this one included, also include the IO operations: INPUT, OUTPUT and HALT. These can be achieved by respectively having A = -1, B = -1 and C = -1. INPUT and OUTPUT read or write singular ASCII characters
Usage