Differences from brainfuck
- Input is loaded into the tape at the beginning of execution.
- Cells can only hold a
- The only instruction that modifies the tape is the 'swap' instruction, which swaps the contents of the current cell with the cell to the right.
||Swaps the values of the current cell and the cell to the right.|
||Move the cell pointer to the left.|
||Move the cell pointer to the right.|
||Jump past the matching |
||Jump back to the matching |
||Adds the bit at the current cell to the output queue. When the output queue reaches a size of 8, it is emptied and the corresponding UTF-8/ASCII character is printed.|
If the input tape contains sufficient consecutive pairs of
1 0, a swapfuck program could trivially operate on each pair as if it was a single, flippable bit.
 loops were replaced with ones that looped while the current cell was zero, not non-zero, a finite input tape of
1 1 1 1 1 1 would allow a program to pretty easily simulate three-cell unbounded brainfuck, which is Turing complete.
The tape is split into 6 interleaved streams of bits. The first stream has a 1 at the position matching the value of the first register, the second stream has a 1 at the position matching the second register, and so on. The other three streams are never permanently modified, and serve only to allow seeking the beginning of the tape while preserving which register is currently selected. This is reducible to 4 bit streams (and therefore 4 1s) if this is not required.
A rough implementation of swapfuck in Lua is available here.