mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 18:18:06 +11:00
acia: make wholly cross compilable
This commit is contained in:
parent
da371451cc
commit
6beb082e29
9
blk/350
9
blk/350
@ -1,9 +1,9 @@
|
|||||||
ACIA driver
|
ACIA driver
|
||||||
|
|
||||||
Manage I/O from an asynchronous communication interface adapter
|
Manage I/O from an asynchronous communication interface adapter
|
||||||
(ACIA). provides "EMIT" to put c char on the ACIA as well as
|
(ACIA). provides "(emit)" to put c char on the ACIA as well as
|
||||||
an input buffer. You have to call "~ACIA" on interrupt for
|
an input buffer from which a provided "(key)" reads. You have
|
||||||
this module to work well.
|
to call "~ACIA" on interrupt for this module to work well.
|
||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
|
|
||||||
@ -12,4 +12,5 @@ ACIA_IO: IO port for the ACIA's data registers
|
|||||||
ACIA_MEM: Address in memory that can be used variables shared
|
ACIA_MEM: Address in memory that can be used variables shared
|
||||||
with ACIA's native words. 8 bytes used.
|
with ACIA's native words. 8 bytes used.
|
||||||
|
|
||||||
Load z80 words with "352 LOAD" and Forth words with "357 LOAD".
|
The whole driver is cross-compilable and is loaded with
|
||||||
|
"352 LOAD"
|
||||||
|
9
blk/352
9
blk/352
@ -1,15 +1,8 @@
|
|||||||
( Save ACIA conf )
|
|
||||||
ACIA_CTL
|
|
||||||
: ACIA_CTL [ LITN ] ;
|
|
||||||
ACIA_IO
|
|
||||||
: ACIA_IO [ LITN ] ;
|
|
||||||
ACIA_MEM
|
|
||||||
: ACIA_MEM [ LITN ] ;
|
|
||||||
( Memory layout
|
( Memory layout
|
||||||
+0 ACIAR>
|
+0 ACIAR>
|
||||||
+2 ACIAW>
|
+2 ACIAW>
|
||||||
+4 ACIA(
|
+4 ACIA(
|
||||||
+6 ACIA) )
|
+6 ACIA) )
|
||||||
|
|
||||||
1 3 LOADR+
|
1 6 LOADR+
|
||||||
|
|
||||||
|
2
blk/353
2
blk/353
@ -1,4 +1,4 @@
|
|||||||
(entry) ~ACIA
|
CREATE ~ACIA
|
||||||
AF PUSHqq,
|
AF PUSHqq,
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
DE PUSHqq,
|
DE PUSHqq,
|
||||||
|
11
blk/356
Normal file
11
blk/356
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
( 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. )
|
||||||
|
|
17
blk/357
17
blk/357
@ -1 +1,16 @@
|
|||||||
1 3 LOADR+
|
: (key)
|
||||||
|
( inc then fetch )
|
||||||
|
ACIAR> @ 1+ DUP ACIA) @ = IF
|
||||||
|
DROP ACIA( @
|
||||||
|
THEN
|
||||||
|
( As long as R> == W>-1, it means that buffer is empty )
|
||||||
|
BEGIN DUP ACIAW> @ = NOT UNTIL
|
||||||
|
ACIAR> !
|
||||||
|
ACIAR> @ 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!
|
||||||
|
;
|
||||||
|
27
blk/358
27
blk/358
@ -1,13 +1,16 @@
|
|||||||
0x20 CONSTANT ACIABUFSZ
|
: ACIA$
|
||||||
|
H@ DUP DUP ACIA( ! ACIAR> !
|
||||||
( Points to ACIA buf )
|
1+ ACIAW> ! ( write index starts one position later )
|
||||||
: ACIA( [ ACIA_MEM 4 + LITN ] ;
|
0x20 ( buffer size ) ALLOT
|
||||||
( Points to ACIA buf end )
|
H@ ACIA) !
|
||||||
: ACIA) [ ACIA_MEM 6 + LITN ] ;
|
( setup ACIA
|
||||||
( Read buf pointer. Pre-inc )
|
CR7 (1) - Receive Interrupt enabled
|
||||||
: ACIAR> [ ACIA_MEM LITN ] ;
|
CR6:5 (00) - RTS low, transmit interrupt disabled.
|
||||||
( Write buf pointer. Post-inc )
|
CR4:2 (101) - 8 bits + 1 stop bit
|
||||||
: ACIAW> [ ACIA_MEM 2 + LITN ] ;
|
CR1:0 (10) - Counter divide: 64 )
|
||||||
( This means that if W> == R>, buffer is full.
|
0b10010110 [ ACIA_CTL LITN ] PC!
|
||||||
If R>+1 == W>, buffer is empty. )
|
( setup interrupt )
|
||||||
|
0xc3 0x4e RAM+ C! ( c3==JP, 4e==INTJUMP )
|
||||||
|
~ACIA 0x4f RAM+ !
|
||||||
|
(im1) ;
|
||||||
|
|
||||||
|
16
blk/359
16
blk/359
@ -1,16 +0,0 @@
|
|||||||
: (key)
|
|
||||||
( inc then fetch )
|
|
||||||
ACIAR> @ 1+ DUP ACIA) @ = IF
|
|
||||||
DROP ACIA( @
|
|
||||||
THEN
|
|
||||||
( As long as R> == W>-1, it means that buffer is empty )
|
|
||||||
BEGIN DUP ACIAW> @ = NOT UNTIL
|
|
||||||
ACIAR> !
|
|
||||||
ACIAR> @ C@
|
|
||||||
;
|
|
||||||
: (emit)
|
|
||||||
( As long at CTL bit 1 is low, we are transmitting. wait )
|
|
||||||
BEGIN ACIA_CTL PC@ 0x02 AND UNTIL
|
|
||||||
( The way is clear, go! )
|
|
||||||
ACIA_IO PC!
|
|
||||||
;
|
|
16
blk/360
16
blk/360
@ -1,16 +0,0 @@
|
|||||||
: ACIA$
|
|
||||||
H@ DUP DUP ACIA( ! ACIAR> !
|
|
||||||
1+ ACIAW> ! ( write index starts one position later )
|
|
||||||
ACIABUFSZ ALLOT
|
|
||||||
H@ ACIA) !
|
|
||||||
( setup ACIA
|
|
||||||
CR7 (1) - Receive Interrupt enabled
|
|
||||||
CR6:5 (00) - RTS low, transmit interrupt disabled.
|
|
||||||
CR4:2 (101) - 8 bits + 1 stop bit
|
|
||||||
CR1:0 (10) - Counter divide: 64 )
|
|
||||||
0b10010110 ACIA_CTL PC!
|
|
||||||
( setup interrupt )
|
|
||||||
0xc3 0x4e RAM+ C! ( c3==JP, 4e==INTJUMP )
|
|
||||||
['] ~ACIA 0x4f RAM+ !
|
|
||||||
(im1) ;
|
|
||||||
|
|
@ -12,21 +12,20 @@ RAMSTART 0x70 + CONSTANT ACIA_MEM
|
|||||||
: CODE XCODE ;
|
: CODE XCODE ;
|
||||||
: IMMEDIATE XIMM ;
|
: IMMEDIATE XIMM ;
|
||||||
: (entry) (xentry) ;
|
: (entry) (xentry) ;
|
||||||
|
: CREATE XCREATE ;
|
||||||
: : [ ' X: , ] ;
|
: : [ ' X: , ] ;
|
||||||
|
|
||||||
CURRENT @ XCURRENT !
|
CURRENT @ XCURRENT !
|
||||||
|
|
||||||
282 LOAD ( boot.z80 )
|
282 LOAD ( boot.z80 )
|
||||||
352 LOAD ( acia.z80 )
|
|
||||||
372 LOAD ( sdc.z80 )
|
|
||||||
393 LOAD ( icore low )
|
393 LOAD ( icore low )
|
||||||
|
352 LOAD ( acia )
|
||||||
|
372 LOAD ( sdc.z80 )
|
||||||
415 LOAD ( icore high )
|
415 LOAD ( icore high )
|
||||||
(entry) _
|
(entry) _
|
||||||
( Update LATEST )
|
( Update LATEST )
|
||||||
PC ORG @ 8 + !
|
PC ORG @ 8 + !
|
||||||
422 437 XPACKR ( core )
|
422 452 XPACKR ( core print fmt readln )
|
||||||
358 360 XPACKR ( acia.fs )
|
|
||||||
438 452 XPACKR ( print fmt readln )
|
|
||||||
123 132 XPACKR ( linker )
|
123 132 XPACKR ( linker )
|
||||||
," : _ ACIA$ RDLN$ (ok) ; _ "
|
," : _ ACIA$ RDLN$ (ok) ; _ "
|
||||||
ORG @ 256 /MOD 2 PC! 2 PC!
|
ORG @ 256 /MOD 2 PC! 2 PC!
|
||||||
|
Loading…
Reference in New Issue
Block a user