AVR Brainf**k interperter.



++++[>++++<-]>+[<+++++>-]<.


Who?
  me, duh...

What?
  Sorry, this is NOT an arduino project :-)
 This is NOT a compiler for BF programs to run on avrs.
 This is a B.F. INTERPRETER that runs on an 'atmega32' avr. There are 3 ports used. PORTA is used as an output, PORTB is used as an input, 3 bits of PORTC are used for status (running, missing bracket, or program finished (see code)).
The implementation is really simple there aren't even sigmals to synchronize the IO.
The interpreter is flashed to the avr, and the BF program is flashed to the avrs EEPROM. This limits the BF program to 1022 bytes.

Why?
   I had all the code, why not? Also, I'd really like to put it out there and see if anyone does anything with it, there is nothing cooler than a pointless application of a pointless creation. Take this code and modify it however you want. If you use it in a commercial project you have to open source the rest of the project. ;-)

 When?
  ok, I'm feeling template questions here?...

How?
  I'm glad you asked!
 I'm going to assume your familiar with programming your avr.
 I'm also assuming your running linux, interpret as desired.
 You need to download 2 things, the avr code, and a program to preformat the BF code.
 
1) Download and unpack the software(s)
  - avr code
  - preformatter
 wait I made this easier, just one tgz file

  > wget http://ruemohr.org:/~ircjunk/tutorials/prog/avrbf/avrbf.tgz
  > tar -xzvf bfavr.tgz
  > cd bfavr

2) Compile the avr software
  > cd bfavr
  > make clean; make

The source code consists of main.c and main.h, main.h is empty.
Software is written for an atmega32.

3) Compile utility program.
> gcc ../zpad/main.c -o zpad

4) upload the firmware
> make usbinstall

This assumes a avrisp2 usb programmer, use your favorite programmer with avrdude as you like.

5) pre-process the BF code.
> ./zpad ../bf/Ox55.bf  bfmain.raw

This program merely puts a 0x00 at the front and end of the program so that the firmware can find the ends of it when searching for loop brackets. If you want to do it another way, but all means go ahead.

Ox55.bf is a program that just outputs 0x55, this is nonally ascii U but also is 01010101 a handy letter indeed.

6) upload the BF code to eeprom
> avrdude -c avrisp2 -P usb -p atmega32 -U eeprom:w:bfmain.raw:r

again, use your favorite avrdude and or programmer command.

7) observe results

as soon as the BF code is loaded into eeprom, the avr will reset and your program starts running.

8) modify

I didn't write this to just be this, make it do something, post the result to HaD or something.
I want to see this running a nuclear plant or decrypting wireless keys within a week ok?

Rue Mohr.