esolang

Bitwise Fuckery

Brainfuck with a second tape, and the bitwise operators to mix the two.

caird coinheringaahing · Turing complete: yes · ●●○ moderate

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

Run it

Expected: cat me

The idea

Bitwise Fuckery keeps the eight brainfuck commands and adds a second tape that shares the pointer. The commands still act on the first tape, but % swaps the current cell with the one below it, @ swaps the whole tapes, and ^ & | combine the two cells into the first. ~ flips every bit, and { } shift the first cell by the second.

The machine

Two tapes of unbounded integers that start with one cell each and grow together to the right. Moving left from cell 0 lands on the last cell. Cells never wrap; - on 0 gives -1, and so does , at the end of the input. . prints the character whose code is the cell's absolute value, as UTF-8.

CommandDoes
+ - > < , .As in brainfuck, on the first tape
[ ]Loop while the first cell is not 0
( )Skip to the ) when the first cell is 0
%Swap the current cells of the two tapes
@Swap the two tapes
^ & \|First cell becomes its XOR, AND or OR with the second
~First cell becomes -x-1
{ }Shift the first cell left or right by the second

This implementation follows the Python interpreter in caird coinheringaahing's repository Bitwise-Fuckery, which is what TIO runs. Its README says loops test the lowest bit; the source tests the whole cell.

Example

The second program puts 6 on the lower tape, sets the upper cell to 1, shifts it left by 6 to get 64,…
Expected: A

The second program puts 6 on the lower tape, sets the upper cell to 1, shifts it left by 6 to get 64, adds 1 and prints A.

Patterns it teaches

  • Turing tarpit: every brainfuck program is still a program, so it is as complete.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Bitwise Fuckery

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run bwfuckery -e ',+[-.,+]' --input 'cat me'
shib manual bwfuckery

Source

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

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