mikaelpatel / Arduino-Shell

RPN Postscript/Forth Command Shell for Arduino
19 stars 5 forks source link

Enhance: Add instructions for TWI #8

Closed mikaelpatel closed 8 years ago

mikaelpatel commented 8 years ago

I2C requires at least two function; twi-read ( n addr -- x1 ... xn) and twi-write ( x1 ... xn n addr -- ). Many driver functions have the form;

reg 1 addr twi-write n addr twi-read // read a register
val reg 2 addr twi-write // write a register
dpharris commented 8 years ago

Using stack markes is elegant:

[_reg] _addr $I 
2 _addr $i
[23 _reg] _addr $I
[2,3,4,5] _addr $I

(I used $I for twi-write and $i for twi-read)

mikaelpatel commented 8 years ago

Yes, the stack marker and operations are great contribution by PostScript. Much more rethinking stack machines was done in the design.

I have changed the extended instruction set handling (trap) to a general trap on any op-code that was not handled. The trap handler can parse any number of op-codes.