From 9424770caa3d16eb5a85ff6738d0d3ef1b49f4ff Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 28 Jun 2020 17:30:01 -0400 Subject: [PATCH] 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. --- blk/581 | 16 ++++++---------- blk/582 | 22 +++++++++++++++------- blk/583 | 5 ++--- blk/584 | 6 ++---- blk/585 | 6 ++---- blk/586 | 10 ---------- blk/587 | 10 +++++----- blk/588 | 6 +++--- blk/618 | 5 ++--- 9 files changed, 37 insertions(+), 49 deletions(-) delete mode 100644 blk/586 diff --git a/blk/581 b/blk/581 index b6e6a98..c54687a 100644 --- a/blk/581 +++ b/blk/581 @@ -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. diff --git a/blk/582 b/blk/582 index 54933a8..91de737 100644 --- a/blk/582 +++ b/blk/582 @@ -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. ) diff --git a/blk/583 b/blk/583 index 6f49f02..1bac543 100644 --- a/blk/583 +++ b/blk/583 @@ -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. ) diff --git a/blk/584 b/blk/584 index d2b0515..5ccb3b2 100644 --- a/blk/584 +++ b/blk/584 @@ -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, diff --git a/blk/585 b/blk/585 index 2b2a8ae..f8b5738 100644 --- a/blk/585 +++ b/blk/585 @@ -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, diff --git a/blk/586 b/blk/586 deleted file mode 100644 index a236b96..0000000 --- a/blk/586 +++ /dev/null @@ -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. ) diff --git a/blk/587 b/blk/587 index bd73fd4..9b91d38 100644 --- a/blk/587 +++ b/blk/587 @@ -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 ) diff --git a/blk/588 b/blk/588 index 41a635a..7b11043 100644 --- a/blk/588 +++ b/blk/588 @@ -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. diff --git a/blk/618 b/blk/618 index ab903a7..83d6047 100644 --- a/blk/618 +++ b/blk/618 @@ -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 )