SFIN
Four instructions and one gate. A bit changes only by NAND with a single bit of memory.
2023 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
SFIN stands for Simple Four-Instruction Nand. It was made in 2023, after brainfuck and NAND logic. There are four bits and one bit of memory. The only way to change a bit is to NAND it with the memory bit, so copying one bit into a cleared one takes five commands besides the moves.
Read the story
Input, output and loops have no commands of their own. They come from repeating one. Two question marks make a syscall, and what the syscall does depends on the current bit and the memory bit. Two bars jump to the first mark when the memory bit is 0.
The machine
| Command | Does |
|---|---|
> | Move to the next bit, wrapping at the end |
? | Copy the current bit to memory |
v | Set the current bit to NOT (bit AND memory) |
\| | Mark a place |
n times ? | n-1 syscalls |
n times \| | If memory is 0, jump to mark n-1 |
| Bit | Memory | Syscall |
|---|---|---|
| any | 1 | Print the bit as 0 or 1 |
| 0 | 0 | Double the number of bits |
| 1 | 0 | Read a bit into the cell |
So reading needs a 1 in the cell first, and printing needs a 1 in memory. Every other character is passed over, and the marks count in the order they stand in the program.
Example
The XOR.
The XOR. It reads two bits, works out b1 NAND b2 in a third, NANDs each input with it and the two results together, then sets the fourth bit to 1 so that memory holds a 1 to print with.
The truth machine. After reading, the second bit holds the inverse of the input, and the loop goes back to the mark while it is 0. On 1 it prints 1 forever.
Patterns it teaches
- Turing tarpit: one gate, and thespecification thinks Boolfuck fits in it.
Further
See also
Cell-based
Write your own in Run Convert a program from SFIN
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: sfin.
Command line
shib run sfin -e 'v??
>>>>?>vv>v
|
?
>>??
>?
>
||' --input '0'shib manual sfinSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/sfin.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org