

        AT LAST!  BRAINF*** FOR THE TI-83!

    Summary:

        These two programs, BFIACC and BFIFAST, are TI-based
        interpreters for the computer language Brainf*** (the
        asterisks represent a naughty word which also happens to
        be an apt description of the language).  BFIFAST is
        faster, while BFIACC simulates the more traditional
        character-based I/O scheme.

    The Language:

        Brainf*** was invented and first implemented by Urban
        Mueller; you can find plenty of resources online,
        including the original interpreter and many different
        compilers.  The language was designed to be small, and
        in fact it has only eight instructions:

            char    meaning                 C equivalent

            >       move pointer right      ++p;
            <       move pointer left       --p;
            +       increment this cell     ++(*p);
            -       decrement this cell     --(*p);
            [       begin a while loop      while (*p) {
            ]       end a while loop        }
            ,       input a cell's value    *p = getchar();
            .       output a cell's value   putchar(*p);

        Despite this limited character set, Brainf*** is
        provably Turing-complete (don't worry about it).

        Anyway, these programs take Brainf*** programs and
        interpret them on your TI-83 calculator.  The program to
        be executed should be stored in Str1.  Both interpreters
        overwrite L1 and L2 during execution as well as using
        Str1.

    Differences between BFIFAST and BFIACC:

        The first interpreter, BFIFAST, implements the , and .
        operations as simple numerical procedures: Input and
        Disp, respectively.

        The second interpreter, BFIACC, simulates the experience
        you'd get from running a typical BFI on a Unix system.
        In other words, all I/O is buffered and character-based;
        carriage returns (ENTER key) have value 10 decimal, and
        all other ASCII characters have their normal ASCII
        values.  All non-ASCII characters are treated as value
        -1 (often used as an end-of-file marker in Brainf***
        programs), except the degrees symbol, which stands in
        for the double quote (") as ASCII value 34.
        BFIACC buffers input and output, discarding all unused
        input and displaying all undisplayed output at the end
        of the program.

        BFIACC overwrites Str2, Str3, and Str9 as well as L1 and
        L2.

    Testing:

        Here is a sample program to try:

            "[-]+++++++++[>++++++++<-]>.---.+++++++..+++.<++++++
            +++[>-----<-]>-."\STO->\Str1
            prgmBFIACC

        It prints "HELLO!"
        This program echoes your input:

            ",+[-.,+]"\STO->\Str1
            prgmBFIACC

        Incidentally, unless your program does a lot of I/O,
        BFIFAST is not that much faster than BFIACC.  On the
        "HELLO!" program above, BFIACC took 28 seconds while
        BFIFAST took 24.

        (You see how efficient Brainf*** programs are :-)

    Technical details:

        The maximum program length for these interpreters is 99
        characters (the length of L2).  The array on which the
        pointer operates is 99 bytes long, and wraps around at
        both ends.  Cell values range from 0 to 255.  BFIACC
        will output question mark characters (?) instead of
        various non-TI ASCII values (#, %, ~...) and for all
        cell values greater than 126.
        Note that in BFIACC, you can't enter two consecutive
        carriage returns; the OS won't let you.  And while you
        can enter double quote marks ("), the interpreter can't
        display them; so quote marks are treated as non-ASCII
        characters (value -1), and the degrees symbol is treated
        in both input and output as ASCII value 34.

    Conclusion:

        Have fun with these interpreters, and especially if you
        make any (speed-wise) improvements on them, send your
        comments to

                Arthur O'Dwyer
                arthur_odwyer at yahoo.com

        Don't send me mail asking for help with the language
        Brainf***, though, because I'm nowhere near proficient
        in it.  Check the Internet first.

        Have fun Brainf***ing!

                                                -Arthur O'Dwyer
                                                 2 April 2002

