LayerASM is an esoteric programming language created by User:Ashtons which works with four data grid layers which contain different types of data, and supports four instructions.
As stated previously, there are four data layers that contain a different data type each. Each data layer is a grid of 16 by 16 cells, with each cell containing one value. This could be infinite, but computers do not have infinite amounts of memory.
|Layer||Data Type||Bytes per Cell||Total Size (Bytes)|
Combining the size of all layers, 2,048 bytes (2 kibibytes) of memory are used for data.
LayerASM has only four instructions which take one or three arguments.
- `do` - takes in an operation to perform on the current data cell. Operations are increment, decrement, double, halve, input, and output
- `mv` - takes in a direction and moves the data cell pointer one cell in that direction
- `jp` - takes a direction, a condition, and a label and jumps to the label if the current cell and cell in the given direction meet the given condition
- `cl` - takes a layer ID and changes the current data layer to the given layer. Each layer has a different data cell pointer.
LayerASM code has to be compiled into bytecode. Each instruction has a different bytecode representation. While `jp` uses two bytes, the rest of the instructions can be represented using only one byte.
'do' is represented in bytecode as 00101???, where the ?s are the bits for the operation argument. Each operation is represented as follows:
- increment is 000
- decrement is 001
- double is 010
- halve is 011
- input is 100
- output is 101
'mv' is represented in bytecode as 01??0010, where the ?s are the bits for the direction argument. Up is 00, Down is 01, Right is 10, and Left is 11.
'jp' also has a direction argument, but it also has a condition argument and a label argument. Rather than writing out the label in ASCII in the bytecode, the label is turned into an 8-bit signed displacement. As such, 'jp' is represented as 10??1??? ????????, first two ?s are direction, next 3 ?s are condition, and the rest of the ?s is the displacement byte. The conditions are represented as so:
- always jump is 000
- jump if equal or zero is 001
- jump if not equal or not zero is 010
- jump if less than is 011
- jump is more than is 100
'cl' is represented in bytecode as 11??1001, where the ?s are the layer ID.
The official notation for different arguments are as follows.
- increment is `in`
- decrement is `de`
- double is `db`
- halve is `hl`
- input is `i`
- output is `o`
- down is `dn`
- right is `rt`
- left is `lf`
- jump always is `a`
- jump if equal or zero is `z`
- jump if not equal or not zero is `nz`
- jump if less than is `lt`
- jump if greater than is `gt`
Bytecode Compiler: To Be Coded
Bytecode Interpreter: To Be Coded