```

From Esolang
Jump to navigation Jump to search

``` is an extremely minimalistic programming language. It operates on cells, which can store unbounded numbers.

Commands

There is only a single command, but that command have multiple forms.

Forms
Form What it does
`a`#b Store the number b in cell a.
`a`b Copy cell b into cell a.
``a`#b Store the number b into the address that cell a points to.
``a#b`#c Store the number c in the address cell a points to offset by b.
``a`b`#c Store the number c in the address cell a points to offset by the contents of cell b.
`a``b Fetch the value the address that cell b points to and store it in cell a
`a``b#c Fetch the value the address that cell b points to, offset by c, and store it in cell a
`a``b`c Fetch the value the address that cell b points to, offset by the value in cell c and store it in cell a
``a`b Store the value in cell b into the address cell a points to.
``a#b`c Store the value in cell c into the address cell a points to, offset by b.
``a`b`c Store the value in cell c into the address cell a points to, offset by the contents of cell b.

Architecture

The program memory's conformation mingles those cells of Procrustean efficacy, restricted to the reception and elicitation of data without a further epiphenomenal potential, with special-purpose locations that endow the programming language with behoovable competences.

The following illustration shall limn a cursory simulacrum of the memory layout, its components being accessible by respective anchors to the appertaining elucidations below:

Purpose IP Conditional execution I/O switch I/O mode I/O storage General purpose
Address 0 1 2 3 4–24 25–

IP: The cell located at the address 0 maintains the instruction pointer (IP). If manipulated by an operation, its new state designates the subsequent instruction's zero-based index to execute; otherwise, ensuing from an completed evaluation, the next member in the program is selected. Modifications applied on this cell capacitate the control flow's steering.

Conditional execution switch: The cell answering to the index 1 capacitates the activation or deactivation of the conditional execution facility. If a non-zero value is written to this place, no instructions are executed, except for those intended for the manipulation of the address 1 itself. A cell state of zero, as constitutes the default, deactivates this conditional skipping behavior.

Input/Output switch: The cell 2 serves to enable or disable the input/output conduits. Writing a non-zero value to this location either issues an output or causes an input request, depending on the input/output mode setting, which please see below. Immediately succeeding from the completed interaction, the value of cell 2 resets to its default of 0.

Input/Output mode: The cell address 3 specifies the input/output mode, that is, whether an interaction request shall be interpreted as a print or input order, actuated when the cell at the index 2, this being the input/output switch receives a non-zero value. The mode depends on the state of the cell 3:

  • A state of 0 issues output: The 21 cells commencing at the inclusive memory address 4 and extending to the inclusive terminal position 24 are interpreted as a Unicode code point, the lower address of 4 conflating with the code's binary representation's most significant bit (MSB), the last address of 24 referencing the least significant one (LSB). This character corresponding to this code point is subsequently printed to the standard output.
  • A state of 1 requests input: A single Unicode character is queried from the standard input conduit, and its Unicode code point's bits are written to the memory segments 4 through 24, again assigning the bit format's highest position to the memory address 4, its lowest to 24.

Input/Output storage: The 21 cells commencing from the inclusive address 4 through the inclusive address 24 are reserved for the input and output actions, accommodating the space for a single Unicode character's maximum of 21 bits necessary to replicate the code point's binary representation in the memory.

Examples

Cat Program

A perpetually repeating cat program is presented below:

`3`#1
`2`#1
`3`#0
`2`#2
`0`#0

Truth-Machine

The following implements a truth-machine:

`3`#1
`2`#1
`3`#0
`2`#2
`1`24
`0`#8
`1`#0
`0`#3

Indirection and Skipping

This program demonstrates the utilization of indirection in order to manipulate the instruction pointer (IP) cell at the address zero (0), a reference to whom is maintained in the cell at the address 25, ultimately skipping the two instructions responsible for the request of input:

`25`#0
``25`#4
`3`#1
`2`#1

Interpreter

  • Common Lisp implementation of the ``` programming language.