BrainFuck
This page was last modified 15:04, 19 August 2018 by Gdx. Based on work by Jorito.

BrainFuck is a very simple language that contains only 8 instructions:

Character Meaning
> increment the data pointer (next memory address).
< decrement the data pointer (previous memory address).
+ increment (increase by one) the byte at the data pointer.
- decrement (decrease by one) the byte at the data pointer.
. output a byte from data pointer to standard output.
, get byte from standard input and store it to memory address pointed by data pointer.
[ if the byte at the data pointer is zero, then instead of moving the Program Counter forward to the next command, jump it forward to the command after the matching ] command.
] if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.


There exists few BrainFuck interpreters for MSX like this one from Arjan Backer:

1 IFGTHENRESUMENEXTELSEDEFINTA-Z:ONERRORGOTO1:G=&H9000:FORD=GTO&H9100:POKED,0:NE
XT:INPUT"File:";H$:OPENH$FORINPUTAS1:P=&HA000:FORA=2TOLOF(1):POKEP,ASC(INPUT$(1,
1)):P=P+1:NEXT:POKEP,43:POKEP+1,91:POKEP+2,93:CLOSE:P=&H9FFF:PRINT"Running..."
2 P=P+1:C=PEEK(P):G=G+(C=60)-(C=62):V=PEEK(G):POKEG,V+(C=45)-(C=43):POKEG,ASC(IN
PUT$(-(C=44))):PRINTCHR$(VAND(-255*(C=46)));:IFC=91ANDV=0ORC=93ANDVTHENL=1:I=92-
C:FORA=0TO1:P=P+I:C=PEEK(P):L=L-(C=91)*I+(C=93)*I:A=-(L=0):NEXT:GOTO2ELSEGOTO2

There exists also BrainFuck compiler by NYYRIKKI

This example program prints "Hello World!"

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

This example program prints Sierpinski triangle:

[ This program prints Sierpinski triangle on 80-column display. ]
                                >    
                               + +    
                              +   +    
                             [ < + +    
                            +       +    
                           + +     + +    
                          >   -   ]   >    
                         + + + + + + + +    
                        [               >    
                       + +             + +    
                      <   -           ]   >    
                     > + + >         > > + >    
                    >       >       +       <    
                   < <     < <     < <     < <    
                  <   [   -   [   -   >   +   <    
                 ] > [ - < + > > > . < < ] > > >    
                [                               [    
               - >                             + +    
              +   +                           +   +    
             + + [ >                         + + + +    
            <       -                       ]       >    
           . <     < [                     - >     + <    
          ]   +   >   [                   -   >   +   +    
         + + + + + + + +                 < < + > ] > . [    
        -               ]               >               ]    
       ] +             < <             < [             - [    
      -   >           +   <           ]   +           >   [    
     - < + >         > > - [         - > + <         ] + + >    
    [       -       <       -       >       ]       <       <    
   < ]     < <     < <     ] +     + +     + +     + +     + +    
  +   .   +   +   +   .   [   -   ]   <   ]   +   +   +   +   +    
 * * * * * M a d e * B y : * N Y Y R I K K I * 2 0 0 2 * * * * *

More about BrainFuck: http://en.wikipedia.org/wiki/Brainfuck