VIEW ALL DOCS

Brainfuck!, the language

NOTE: This is not an exhaustive documentation/representation of the Brainfuck! language, merely a documentation for ABF-specific aspects.

Brainfuck! is an esoteric programing language that is a minor extension of the BrainFuck language that is "technically" turing complete with only 9 opcodes:

Consult the wikipedia for the full history of the original Brainfuck language.

  • > : Shift the data pointer to the right
  • < : Shift the data pointer to the left
  • + : Increment the byte at the data pointer
  • - : Decrement the byte at the data pointer
  • . : Output the byte at the data pointer
  • , : Accept a byte of input at the data pointer
  • [ : If the byte at data pointer is zero, skip code until ]
  • ] : If the byte at data pointer is nonzero, go back in code until [
  • ! : Jumps the data pointer to zero. (Extra opcode added to Brainfuck)

That's it. Any other characters in your code is ignored and are considered comments.

ABF implements the Brainfuck! language on-chain in the BrainfuckVM contract with a few specific configurations:

  1. The data pointer has a range of 0-299,999. This means you can utilize up to 300,000 byte slots to store data in your Brainfuck! runtime.
  2. Underflow and overflow bytes cause the byte to 'roll over', as in incrementing 0xFF will become 0x00.
  3. There is a maximum of 8192 nested [] allowed. Exceeding that will cause ABF to crash.
  4. A maximum of 10000 code jumps because of [ or ] are allowed.

These limitations are the result of the constraints of the EVM environment, we do not expect many ABF NFTs to hit these bounds.

Inputting + Outputting Bytes

ABF provides 64 bytes as input to your Brainfuck! code, each byte read via the , opcode from the most significant byte, in a little-endian context, to the least. (From left to right)

Outputted bytes, via the . code, are appended the the output bytes from the most significant byte, in a little-endian context. (From left to right)

Resources

Writing in Brainfuck! is quite literally a 'brainfuck'. Consult these various resources as well as Google to dive deeper into the language. It's more fun than Assembly and just as f**king annoying.



Ready to join the ABF Corps?

JOIN NOWREAD DOCS