esolang

Flipbit

A tape of bits, and output is the whole tape up to the pointer read as one number.

caird coinheringaahing · Turing complete: unknown · ●●● hard

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: AB

The idea

There are no bytes in Flipbit. ^ flips one bit and > < move. To print, you walk the pointer to the end of the bits you want, and . reads every cell from 0 up to the pointer as a binary number and prints the character with that code. So the pointer's place decides how many bits the character has, and the first cells of the tape are part of every character you print.

The machine

A tape of 3,000 bits, all 0. This implementation follows the Python interpreter in caird coinheringaahing's repository Flipbit, which is what TIO runs.

CommandDoes
^Flip the bit
> <Move; left of cell 0 stays at 0 and clears it
.Print the bits from cell 0 to the pointer as one character
,Copy the next input bit into the cell and move right
?Copy the next 8 input bits over the next 8 cells
[ ]Loop while the bit is 1

The input is one stream of bits, each character's code in binary without leading zeros, so a is the seven bits 1100001. The loops find their partners the way the Python does, by counting how deep they are rather than matching pairs, so nested loops can behave in surprising ways; this implementation keeps that.

Example

The first program sets bits 0 and 6 to get 1000001, which is 65, then moves the second 1 one place left…
Expected: a

The first program sets bits 0 and 6 to get 1000001, which is 65, then moves the second 1 one place left for 66.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Flipbit

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: flipbit.

Command line

shib run flipbit -e ',,,,,,,<.' --input 'a'
shib manual flipbit

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/flipbit.js

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