Jump to content



Photo
- - - - -

Brainfuck Compiler


  • Please log in to reply
No replies to this topic

#1 Kilburn

Kilburn

    Casio Technician

  • Members
  • PipPipPipPipPipPip
  • 491 posts
  • Gender:Male
  • Location:France
  • Interests:Blah

  • Calculators:
    FX-7500 G
    ClassPad 300

Posted 30 December 2008 - 09:52 PM

Hey there, looks like I haven't released any C++ stuff here for a long time. I've been into SH3 assembly for a few weeks, and I was looking for a way to create C functions during runtime. That would be incredibly useful for making dynamically linked libraries (think DLL), or for compiling simple expressions instead of parsing them.

So here we go, I have started with something extremely simple, the Brainfuck language. If you don't know what it is, have a look over there: http://en.wikipedia.org/wiki/Brainfuck

The most interesting part isn't what it does, but how it does it. It directly compiles the Brainfuck script into machine code, so it should theorically run as fast as your average C function.

Get it here, source code included: http://kilburn.ftp.f...assPad/CPBF.rar

Have a look at the source code, because there is really nothing impressive in the add-in itself. Actually, it's very primitive, the console output is produced in the same window as the one you are using for typing your code, so you have to erase it every time you run a program. You can't save your programs, and you really should NOT try to do play with infinite loops, since you will never get out without resetting your calc.


Again, this is purely a proof of concept, I wanted to find a way to create C functions during runtime. Don't expect anything extraordinary from this.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users