1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-14 17:38:05 +11:00
collapseos/blk/587
Virgil Dupras a9ed8da0b2 acia: simplify driver
The previous approach of maintaining R> and W> pointers was
conceptually simple, but made INT handler code actually quite
complex.

Now, we maintain indexes instead. It's much easier to perform
bounds checks and to compare for equality, something we have to
do quick in the INT handler.
2020-08-14 22:58:05 -04:00

15 lines
443 B
Plaintext

: (key)
( inc then fetch )
[ ACIAR> LITN ] C@ 1+ [ ACIA_BUFSZ 1- LITN ] AND
( As long as R> == W>-1, it means that buffer is empty )
BEGIN DUP [ ACIAW> LITN ] C@ = NOT UNTIL
DUP [ ACIA( LITN ] @ + C@ ( ridx c )
SWAP [ ACIAR> LITN ] C! ( c )
;
: (emit)
( As long at CTL bit 1 is low, we are transmitting. wait )
BEGIN [ ACIA_CTL LITN ] PC@ 0x02 AND UNTIL
( The way is clear, go! )
[ ACIA_IO LITN ] PC!
;