DSLua Community
Welcome, Guest. Please login or register.
May 18, 2012, 09:50:59 PM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Home-brew/Hacks/Games/Projects  |  Brainf*** interpreter « previous next »
Pages: [1]
Author Topic: Brainf*** interpreter  (Read 2664 times)
Jeremysr
First Quarter
***
Posts: 215



WWW
« on: November 07, 2006, 11:50:29 PM »

I guess an interpreted language isn't the best type of language to write an interpreter in, but it's the only language I know for the DS. Tongue It's an esoteric language called brainf*** (I'm calling it that because the actual name may not be allowed...maybe no one's here to disallow it but I think "admin" is watching us..'cause he just came within a day of me posting stuff about Waruwaru)

It's about the easiest language to write an interpreter for (I wrote it in almost a day, and added input the next day). It has 8 commands. That's all. Which are "> < - + [ ] . ,". The 8 things you can do are increment the memory pointer, decrement the memory pointer, increment the value that the memory pointer is pointing to, decrementing the value that the memory pointer is pointing to, print out the character the current value that the memory pointer is pointing to's ASCII value, take the ASCII value of a key inputted from the keyboard into the value that the memory pointer is pointing to, and a sort of while loop that is hard to explain. (which takes 2 commands)

More info: http://www.muppetlabs.com/~breadbox/bf/ (Warning: There are badwords on this link. Shocked (Obviously))

Screenshot: http://www.bio-gaming.com/jeremy/dslua/img/brainfk.png

Download (Interpreter + 9 programs that all work except for Towers of Hanoi which takes about 3 minutes to load into memory): http://www.bio-gaming.com/jeremy/dslua/downloads/brainfuckDS.zip

BTW be patient (most of the time) with the speed of loading and running. It's slow. It's an interpreted interpreter.

Sample program (Hello World):

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

« Last Edit: January 20, 2007, 07:12:17 PM by Jeremysr » Logged
TOAST
Waxing Crescent
**
Posts: 67



« Reply #1 on: December 06, 2006, 06:42:52 PM »

Haha, crazy man! Cheesy

Is brainfuck like lowlowlow level, editing the lowlevel system stuffs like C++ pointers?? I have never looked more on it than the helloworld example.. Tongue
Logged
Jeremysr
First Quarter
***
Posts: 215



WWW
« Reply #2 on: December 06, 2006, 07:14:40 PM »

Nope it doesn't change values just anywhere in the memory, the memory pointer doesn't point to an actual memory address (this is DSLua!). The memory pointer actually points to a value in a 30 000-cell array of numbers.
Logged
Pages: [1]
« previous next »
    Jump to: