The Brainfuck Computer

News
Some freak (update: now a friend) actually built a copy of this project, and wrote a multiplication program for it. Here is a picture of it.

Ooops!
It seems like the code I uploaded here didn't work, and I lost the original source code. Now I have rewritten the ROM code, and it works fine. In retrospect it was stupid to not use the internal pull-up resistors in the PIC instead of those 10k pulldown resistors I use now. It would probably reduce power consumption with LEDs off to almost nothing, maybe just a few microamperes.

None of the software projects that I have been working at could be considered useful, but this one is playing in its own division. I built a computer of a PIC16F84A microcontroller, an 8-pin DIP switch (4 pins are N/C) and 8 red 3mm LEDs. Speed? I'm using a 32.768kHz clock crystal - and since the PIC requires about 4 clock cycles for each instruction, the whole thing is running at 8192 instructions every second. Now, here's the best part. The only program is a simple "editor" and a brainfuck interpreter! It's quite inefficient, due to the simplicity of the PIC architecture, so you could expect maybe 100-500 instructions per second from it. It has 68 bytes of RAM, of which 32 can be used by user programs. Programs are stored in the PIC's EEPROM memory (64 bytes), which allows programs up to 128 instructions long (2 3-bit instructions and 2 empty bits per byte).

The largest and most complex program ever written for this fantastic computer (update: look above for a larger program) follows:
,>,[<+>-]<.

This was transfered to the computer by converting the program to a sequence of numbers - 72743021536 - which was, one digit at the time, "typed" using the binary number system. The brainfuck computer is certainly nothing I want to debug code on, even though it is theoretically possible to do so, since I did in fact add some features to make the editor a bit more user-friendly (or rather, slightly less user-hostile). This useful piece of software was written by a friend of mine, Erik, and if you violate his copyright he will probably sue your ass off. You have been warned.

By the way, the one who can guess what this program actually does gets an extra life! (Hint: it will ask for and add two numbers, and then output the result).



ComponentValue
B1-B4DIP switch
C1-C2100pF ceramic
D1-D83mm red LEDs
R1-R91k
R10-R1310k
U1PIC16F84A
X132.786kHz crystal

The best about this project is that you can get all the parts for about two or three US dollars. Assuming Microchip sends you a free PIC, that is, otherwise add a few dollars.

Related files


Home |About me |Chinese |Research |Software |Electronics |Radio