diff --git a/drv/acia.fs b/drv/acia.fs index b1d0320..9772bf5 100644 --- a/drv/acia.fs +++ b/drv/acia.fs @@ -9,21 +9,12 @@ CONFIGURATION 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. ) 0x20 CONSTANT ACIABUFSZ -( Points to ACIA buf ) -(sysv) ACIA( -( Points to ACIA buf end ) -(sysv) ACIA) -( Read buf pointer. Pre-inc ) -(sysv) ACIAR> -( Write buf pointer. Post-inc ) -(sysv) ACIAW> -( This means that if W> == R>, buffer is full. - If R>+1 == W>, buffer is empty. ) - : ACIA$ H@ DUP DUP ACIA( ! ACIAR> ! 1 + ACIAW> ! ( write index starts one position later ) @@ -48,8 +39,9 @@ ACIA_IO: IO port for the ACIA's data registers ( As long as R> == W>-1, it means that buffer is empty ) BEGIN ACIAR> @ 1 + ACIAW> @ = NOT UNTIL - ACIAR> @ C@ + ( inc then fetch ) 1 ACIAR> +! + ACIAR> @ C@ ; : EMIT diff --git a/drv/acia.z80 b/drv/acia.z80 index a4d4a75..6fe5af6 100644 --- a/drv/acia.z80 +++ b/drv/acia.z80 @@ -1,8 +1,18 @@ -( Save ACIA ports from conf ) +( Save ACIA conf ) ACIA_CTL : ACIA_CTL [ LITN ] ; ACIA_IO : ACIA_IO [ LITN ] ; +( 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. ) (entry) ~ACIA AF PUSHqq, @@ -14,26 +24,28 @@ ACIA_IO 0x01 ANDn, ( is ACIA rcv buf full? ) JRZ, L2 FWR ( end, no, wrong interrupt cause. ) - ACIAW> @ LDHL(nn), + ACIAW> LDHL(nn), ( is it == to ACIAR>? ) - DE ACIAR> @ LDdd(nn), + DE ACIAR> LDdd(nn), ( carry cleared from ANDn above ) DE SBCHLss, JRZ, L3 FWR ( end, buffer full ) + DE ADDHLss, ( restore ACIAW> ) ( buffer not full, let's write ) ACIA_IO INAn, (HL) A LDrr, ( advance W> ) HL INCss, - DE ACIAR) @ LDdd(nn), + ACIAW> LD(nn)HL, + DE ACIA) @ LDdd(nn), DE SUBHLss, JRNZ, L4 FWR ( skip ) ( end of buffer reached ) ACIA( @ LDHL(nn), + ACIAW> LD(nn)HL, L4 FSET ( skip ) - ACIAW> @ LD(nn)HL, L3 FSET L2 FSET ( end ) DE POPqq, diff --git a/forth/notes.txt b/forth/notes.txt index a685068..e0aa599 100644 --- a/forth/notes.txt +++ b/forth/notes.txt @@ -115,7 +115,12 @@ those slots...) in boot binaries are made to jump to this address. If you use one of those slots for an interrupt, write a jump to the appropriate offset in that RAM location. -SYSTEM SCRATCHPAD is reserved for temporary system storage. +SYSTEM SCRATCHPAD is reserved for temporary system storage or can be reserved +by low-level drivers. These are the current usages of this space throughout the +project: + +* 0x51-0x53: (c<) pointer during in-memory initialization (see below) +* 0x53-0x5b: ACIA buffer pointers in RC2014 recipes. *** Initialization sequence diff --git a/recipes/rc2014/conf.fs b/recipes/rc2014/conf.fs index 0e76557..72fd928 100644 --- a/recipes/rc2014/conf.fs +++ b/recipes/rc2014/conf.fs @@ -2,4 +2,5 @@ 0xf000 CONSTANT RS_ADDR 0x80 CONSTANT ACIA_CTL 0x81 CONSTANT ACIA_IO +RAMSTART 0x53 + CONSTANT ACIA_MEM diff --git a/recipes/rc2014/run.fs b/recipes/rc2014/run.fs index f53ea6c..96d239b 100644 --- a/recipes/rc2014/run.fs +++ b/recipes/rc2014/run.fs @@ -3,7 +3,7 @@ (c<$) ." Collapse OS" LF ( 0c == CINPTR ) - ' (c<) 0x0c RAM+ ! + ['] (c<) 0x0c RAM+ ! ; INIT