Close

This time really in 1kB

A project log for Brainf*cktor

Standalone brainf*ck computer in less than 1kB of code

jaromir.sukubajaromir.sukuba 12/27/2016 at 07:432 Comments

I finally implemented the "methods and apparatus" from my previous log into reality. It was a bit more "code expensive" than I anticipated due to fact the LCD is divided into two halves with two separate enable pins, what is a bit of PITA if you are trying to squeeze it into as small space as possible.

Nonetheless it works and now my BF interpreter uses really only 1kB of ROM (FLASH, EEPROM, whatever) along MCU and all its peripherals.

I'm working on PCB for this one, planning some demonstration video and some how-to, as folks who have no idea how this could work... probably have no idea how this could work.

Discussions

Ted Yapo wrote 12/27/2016 at 15:40 point

How fast does it execute BF?

  Are you sure? yes | no

jaromir.sukuba wrote 12/27/2016 at 18:13 point

The interpreter isn't optimized for speed very much, I tried to get minimal FLASH footprint.

When running at 16MHz (=4MIPS) iIt takes a few microseconds (~5) to execute average BF instruction. Every 16,384ms the BF execution is stopped to check keys, perform editor tasks and refresh display - that takes approximately 3ms. So, the BF interpreter runs at ~200 thousand BF IPS with 3/16,4 interrupt ratio, giving performance approximately 160kBFIPS.

Note you can roughly quadruple the performance by enabling PLL and running the MCU at 64MHz, giving 16MIPS and something like 650kBFIPS.

I didn't bother though - (the LCD routines would need longer wait routines to cope with faster MCU, increasing FLASH consumption) as the execution speed seems to be OK-ish for short programs expected to be typed via the spartan UI.

  Are you sure? yes | no