esolang

Byte-based Instruction Jumping

Every byte is eight instructions at once, one per bit, and the program rewrites itself as it runs.

Peter, 2022 · Turing complete: conjectured · ●●● hard · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: Hello World!

The idea

Peter made Byte-based Instruction Jumping, BIJ for short, at the turn of 2021 and 2022, after 2 Bits, 1 Byte. A program is an array of bytes with a pointer that walks over it. The pointer runs the byte under it one bit at a time from the left, and each bit is an instruction that is on or off. It finishes all eight bits even when the first one has already moved it away, so a byte mostly works on its neighbours.

Read the story

Besides one accumulator byte, the array is all the memory there is. Its bytes are code and data at once, and the program ends as soon as the pointer steps off either end. Almost any text is a program.

A program can be written three ways. As hexadecimal pairs such as 18 48, as lines of eight instruction names such as mvr ... ... wrt cns ... ... mvr, or as characters of the specification's own table, in which byte 0 is ‘ and byte 24 is ↑.

The machine

BitOffOn
1mvr move rightmvl move left
2nothingjmr jump to the next byte to the right with the same value
3nothingjml jump to the previous byte to the left with the same value
4red store the byte in the accumulatorwrt store the accumulator in the byte
5nothingcns read or print instead
6nothingspc the special forms
7nothingneq make the last move twice if the accumulator differs from the byte
8mvr move rightmvl move left

"The byte" is always the one the pointer is on at that moment. With spc, wrt stores the NAND of the accumulator and the byte, wrt cns shifts the byte by one bit, red does nothing and skips the last move, and red cns does nothing at all.

Example

The Hello World alternates ↑ and a letter.

The Hello World alternates ↑ and a letter. ↑ is byte 24, mvr ... ... wrt cns ... ... mvr. It moves onto the letter, prints it and moves on to the next ↑. After the last letter the pointer steps off the end.

Expected: Hello World!

The truth machine keeps 1 in the accumulator, reads a character into its fourth byte and prints it. The last byte, 9a, then compares. On a 1 it moves right once and lands on itself, so it prints 1 forever. On anything else neq makes it move twice, off the end of the array.

Expected: 0
Expected: x

The specification leaves a few things open. In this implementation "the last move" is always bit 8, input past its end reads as 0, and output is the raw byte. The cat and the "Hello! " loop never stop, as the specification describes.

Patterns it teaches

Further

Self-modifying

Cell-based

Write your own in Run Convert a program from Byte-based Instruction Jumping

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: byte-based-instruction-jumping.

Command line

shib run byte-based-instruction-jumping -e '‘1Ø‘Ü' --input '0'
shib manual byte-based-instruction-jumping

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/byte-based-instruction-jumping.js

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

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