The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: AeroASM on June 20, 2005, 05:09:13 PM

Title: Brainf**k Macros
Post by: AeroASM on June 20, 2005, 05:09:13 PM
For those who don't know, Brainf**k is a minimalist programming language with 8 instructions, with no operands.

http://en.wikipedia.org/wiki/Brainfuck

Someone somewhere wrote a Brainf**k interpreter where you could define your own macros, to make programming easier.
And so I thought, why not use the incredible parsing power of MASM macros?

This is only a basic implementation of the instructions; in the next release I will include some macros. I eventually hope to turn it into a C-style compiler, built on top of Brainf**k.

There are two files: bf.asm contains the basic macros to "assemble" Brainf**k, and test.asm is a sample program that counts from 0 to 9 and then beeps.
Title: Re: Brainf**k Macros
Post by: Vortex on June 20, 2005, 05:37:05 PM
Concerning this amazing language, which can of syntax is that? :green
Title: Re: Brainf**k Macros
Post by: Bieb on June 20, 2005, 06:09:36 PM
Might I ask you what the hell actually inspired to do anything brainfuck related?
Title: Re: Brainf**k Macros
Post by: AeroASM on June 20, 2005, 06:31:53 PM
Boredom. I thought it might be interesting, tried it out, then gave up.
Title: Re: Brainf**k Macros
Post by: Citric on June 22, 2005, 05:38:17 AM
Sounds cool

Have you written, anything in MASM?

Cheer Adam
Title: Re: Brainf**k Macros
Post by: Phil on June 22, 2005, 07:30:06 AM
Is the BF language strong enough to allow the creation of a self-replicating program?

  You know, like:

     c:>type self-rep.source
     abcdefxydebc

     ; then assemble and link to create an exe

     c:>self-rep.exe
     abcdefxydebc

     Sounds like it might be ideal for that!
Title: Re: Brainf**k Macros
Post by: AeroASM on June 22, 2005, 10:35:00 AM
Yes, it is possible; such a program is called a "quine"
Title: Re: Brainf**k Macros
Post by: Phil on July 04, 2005, 07:46:46 AM
Here's a link to self-replicating C quines (http://sreeram.org/programming/selfreplicating.php#small)! The smallest one is really sweet:

main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}

I managed to write one once but mine was more like the 80-line variety with a ton of constant data to do the trick. I'd guess that a BF quine could be a lot short than the C source above!
Title: Re: Brainf**k Macros
Post by: Bieb on July 04, 2005, 09:16:25 PM
But BF can't write to files.
Title: Re: Brainf**k Macros
Post by: Eóin on July 04, 2005, 10:08:36 PM
I believe that a quine need only output its source code to standard out or something similar. Following a link from the page posted by Phil there are examples in many other languages, including BBF.

http://www.nyx.net/~gthompso/quine.htm