Sun Jun 17 14:59:42 EDT 2012

PIC indirect addressing

In general this is a pain in the rear, except when it's possible to
use the FSR registers to keep loop state.  With a bit of tinkering
this doesn't seem to be a big problem.

Makes a lot of sense now why the ColorForth chips have 2 pointer
registers: one source, one dest.  It makes loops over memory a lot lot
more efficient than juggling pointers.  It's really just stdin/stdout.

Anyways, here the new IN1 update using b and a.

\ When filling up the buffer, CNT has AL.  Strip off the bits when
\ sending it out.  We can just use the >a and a> words to access the
\ buffer.

\ Since the location of the buffer is known, these are implemented as
\ macros to make the other code a bit more readable, and to have a
\ more efficient implementation.  Indirect addressing is inefficient
\ since we're already using all 3 pointer registers.

: IN>BD    OUT>BD 4 + ;          \ EP -- BD
: OUT>BD   8 * ;                 \ EP -- BD
: CNT      1 + ;                 \ BD -- BD.CNT    
: IN1/CNT  1 IN>BD CNT ;         \ -- BD.IN1.CNT
: bd@      >m bd-page b! m> @b ; \ addr -- value (fetch in BD page)
: bd!      >m bd-page b! m> !b ; \ value addr -- (store in BD page)
\ These serve as "open/close" for the IN1 buffer.
: a/IN1-begin
    IN1/CNT bd@
    al ! buf-page ah ! ;
: a/IN1-end
    al @
    IN1/CNT bd! ;

\ Single byte access, saving a.
: >IN1 a>r a/IN1-begin >a a/IN1-end r>a ; \ byte --