Browse Source

rc2014: add a declaration part to ACIA drivers

Driver configuration don't need their own words at runtime, we only
need to compile them as literals when compiling words.

Now that we have this "declaration blocks" pattern emerging, it
seems like a good idea to take advantage of this in drivers, both
for simplifying the xcomp unit and to make final binary slimmer.
master
Virgil Dupras 4 years ago
parent
commit
9424770caa
9 changed files with 37 additions and 49 deletions
  1. +6
    -10
      blk/581
  2. +15
    -7
      blk/582
  3. +2
    -3
      blk/583
  4. +2
    -4
      blk/584
  5. +2
    -4
      blk/585
  6. +0
    -10
      blk/586
  7. +5
    -5
      blk/587
  8. +3
    -3
      blk/588
  9. +2
    -3
      blk/618

+ 6
- 10
blk/581 View File

@@ -2,15 +2,11 @@ ACIA driver

Manage I/O from an asynchronous communication interface adapter
(ACIA). provides "(emit)" to put c char on the ACIA as well as
an input buffer from which a provided "(key)" reads. You have
to call "~ACIA" on interrupt for this module to work well.
an input buffer from which a provided "(key)" reads. This driver
installs an interrupt handler at RST38 to handle RX.

CONFIGURATION
To use, begin by loading declarations (B582) before xcomp is
loaded. These declarations provide default values for ports and
memory offsets that you can override. See B582.

ACIA_CTL: IO port for the ACIA's control registers
ACIA_IO: IO port for the ACIA's data registers
ACIA_MEM: Address in memory that can be used variables shared
with ACIA's native words. 8 bytes used.

The whole driver is cross-compilable and is loaded with
"582 LOAD"
Then, in the driver part, load range 583-588.

+ 15
- 7
blk/582 View File

@@ -1,7 +1,15 @@
( Memory layout
+0 ACIAR>
+2 ACIAW>
+4 ACIA(
+6 ACIA) )

1 6 LOADR+
0x80 CONSTANT ACIA_CTL ( IO port for ACIA's control register )
0x81 CONSTANT ACIA_IO ( IO port for ACIA's data registers )
( Address in memory that can be used variables shared
with ACIA's native words. 8 bytes used. )
CREATE ACIA_MEM RAMSTART 0x70 + ,
( Points to ACIA buf )
: ACIA( ACIA_MEM @ 4 + ;
( Points to ACIA buf end )
: ACIA) ACIA_MEM @ 6 + ;
( Read buf pointer. Pre-inc )
: ACIAR> ACIA_MEM @ ;
( Write buf pointer. Post-inc )
: ACIAW> ACIA_MEM @ 2+ ;
( This means that if W> == R>, buffer is full.
If R>+1 == W>, buffer is empty. )

+ 2
- 3
blk/583 View File

@@ -5,10 +5,9 @@
0x01 ANDi, ( is ACIA rcv buf full? )
IFNZ,
( correct interrupt cause )
( +2 == ACIAW> )
ACIA_MEM 2+ LDHL(n),
ACIAW> LDHL(n),
( is it == to ACIAR>? )
( +0 == ACIAR> )
DE ACIA_MEM LDdd(n),
DE ACIAR> LDdd(n),
( carry cleared from ANDi above )
DE SBCHLd, ( cont. )

+ 2
- 4
blk/584 View File

@@ -6,10 +6,8 @@
(HL) A LDrr,
( advance W> )
HL INCd,
( +2 == ACIAW> )
ACIA_MEM 2+ LD(n)HL,
( +6 == ACIA) )
DE ACIA_MEM 6 + LDdd(n),
ACIAW> LD(n)HL,
DE ACIA) LDdd(n),
DE SUBHLd,




+ 2
- 4
blk/585 View File

@@ -1,9 +1,7 @@
IFZ, ( end of buffer reached? )
( yes )
( +4 == ACIA( )
ACIA_MEM 4 + LDHL(n),
( +2 == ACIAW> )
ACIA_MEM 2+ LD(n)HL,
ACIA( LDHL(n),
ACIAW> LD(n)HL,
THEN,
THEN,
THEN,


+ 0
- 10
blk/586 View File

@@ -1,10 +0,0 @@
( Points to ACIA buf )
: ACIA( [ ACIA_MEM 4 + LITN ] ;
( Points to ACIA buf end )
: ACIA) [ ACIA_MEM 6 + LITN ] ;
( Read buf pointer. Pre-inc )
: ACIAR> [ ACIA_MEM LITN ] ;
( Write buf pointer. Post-inc )
: ACIAW> [ ACIA_MEM 2 + LITN ] ;
( This means that if W> == R>, buffer is full.
If R>+1 == W>, buffer is empty. )

+ 5
- 5
blk/587 View File

@@ -1,12 +1,12 @@
: (key)
( inc then fetch )
ACIAR> @ 1+ DUP ACIA) @ = IF
DROP ACIA( @
[ ACIAR> LITN ] @ 1+ DUP [ ACIA) LITN ] @ = IF
DROP [ ACIA( LITN ] @
THEN
( As long as R> == W>-1, it means that buffer is empty )
BEGIN DUP ACIAW> @ = NOT UNTIL
ACIAR> !
ACIAR> @ C@
BEGIN DUP [ ACIAW> LITN ] @ = NOT UNTIL
[ ACIAR> LITN ] !
[ ACIAR> LITN ] @ C@
;
: (emit)
( As long at CTL bit 1 is low, we are transmitting. wait )


+ 3
- 3
blk/588 View File

@@ -1,8 +1,8 @@
: ACIA$
H@ DUP DUP ACIA( ! ACIAR> !
1+ ACIAW> ! ( write index starts one position later )
H@ DUP DUP [ ACIA( LITN ] ! [ ACIAR> LITN ] !
1+ [ ACIAW> LITN ] ! ( write index starts one pos later )
0x20 ( buffer size ) ALLOT
H@ ACIA) !
H@ [ ACIA) LITN ] !
( setup ACIA
CR7 (1) - Receive Interrupt enabled
CR6:5 (00) - RTS low, transmit interrupt disabled.


+ 2
- 3
blk/618 View File

@@ -1,13 +1,12 @@
0x8000 CONSTANT RAMSTART
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
0x80 CONSTANT ACIA_CTL 0x81 CONSTANT ACIA_IO
4 CONSTANT SDC_SPI
5 CONSTANT SDC_CSLOW 6 CONSTANT SDC_CSHIGH
RAMSTART 0x70 + CONSTANT ACIA_MEM
582 LOAD ( acia decl )
212 LOAD ( z80 assembler )
262 LOAD ( xcomp ) 282 LOAD ( boot.z80.decl )
270 LOAD ( xcomp overrides ) 283 335 LOADR ( boot.z80 )
353 LOAD ( xcomp core low ) 582 LOAD ( acia )
353 LOAD ( xcomp core low ) 583 588 LOADR ( acia )
380 LOAD ( xcomp core high )
(entry) _
( Update LATEST )


Loading…
Cancel
Save