BFI
brainfuck interpreter
By Dean Scarff

10 Sept 2003, Revision 0.9

  Brainf*** is a Turing complete programming language with just
eight instructions.  This is yet another brainf*** interpreter, this time for the TI-86.

  I've implemented some error-checking, which hopefully will cover 
most of what's thrown at it.  Note this does not extend to iteration
checking: "+[]" for example will pwn your TI; you'll have to reset.

BASIC USAGE:
 1)  Transfer the pre-packaged bfi.86g, which includes the assembled 
     bfi and a sample BF source, to your TI-86.
 2)  Use

	Asm(bfi

     on the home screen, or in a BASIC program.  If you have a
     shell, you can use that instead.   The BASIC Prgm variable
     "BF" should contain the brainfuck source to be executed.

EXIT STATUSES:
  ERROR 10 DATA TYPE: BF not an unlocked, untokenized BASIC Prgm
  ERROR 14 UNDEFINED: BF variable not found
  ERROR 18 ILLEGAL NEST: Unmatched '[' or ']'
  ERROR 19 BOUND: Tape exhausted on '<' or '>'
  (no error): newline, then the usual assembly "Done".

CHARACTER SEMANTICS:
  Due to the differences between TI-86 character representations,
ASCII, and the types of characters accessible through the _getkey
routine, the ',' instruction will behave differently compared to,
say, x86 interpreters using a C getchar function.  Some keys will
assign a valid character to the cell, but nothing will be echoed.
  The characters directly accessible from the keypad (0-9, a-z,
A-Z, +*-/ etc) will all behave as expected.
  The enter character will just act as a linefeed, I bypassed the
TI-86 _putc behaviour of adding a ':' to the next line.  Also, be
aware that none of the ASCII EOL characters (CR, LF) will actually
act like an EOL.  Lenter is 0xd6.
  Since it is often useful to know how to input a null character:
the right key will do it for you, among others.  Keep in mind that
the null character is a printing character.  The space character,
0x20, is the only blank character.
  After each character is read with ',', it is echoed (providing it
is printable) and the cursor is advanced.  There is no sequence to
delete or clear these characters.  The same applies to using '.':
there is no escape sequence that will allow you to move the cursor
back.

LIMITS:
  By default, the tape length is only 255.  This is to save a few
cycles when clearing the tape, since very few BF sources use more
than 255 cells.  You can change this by reassembling with a greater
value of TAPE_LENGTH.
Since each cell is one byte, it can hold 256 ordinal values.  It is
safe to assume arithmetic overflow will work.
  There is a maximum nesting level of 2^16 - 1.  Note that this is 
*not* error-checked.
  The source variable will have the usual variable limit of 65535,
but I don't recommend it being any more than 8k.

PORTABILTY:
  This has been tested on my TI-86 with ROM v1.6.  I use a few ROM
hacks, and I'm not sure how portable they are.

BUG-REPORTS:
  Feel free to contact me with problems and comments.

CHANGES:
0.9:
	* Used ROM _cphlde and sbc for 16-bit register comparison
	* Used call table _ldHLind instead of $0033h
	* Shuffled code around to use more jr instead of jp
	* 16-bit nesting counter
	* Minor documentation updates/fixes
0.8:
	* First public release

-- Dean
censored by request.