mirror of
https://github.com/hsoft/collapseos.git
synced 2024-09-08 02:58:46 +10:00
56 lines
1.2 KiB
Z80 Assembly
56 lines
1.2 KiB
Z80 Assembly
( 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,
|
|
HL PUSHqq,
|
|
DE PUSHqq,
|
|
|
|
( Read our character from ACIA into our BUFIDX )
|
|
ACIA_CTL INAn,
|
|
0x01 ANDn, ( is ACIA rcv buf full? )
|
|
JRZ, L2 FWR ( end, no, wrong interrupt cause. )
|
|
|
|
ACIAW> LDHL(nn),
|
|
( is it == to ACIAR>? )
|
|
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,
|
|
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 )
|
|
L3 FSET L2 FSET ( end )
|
|
|
|
DE POPqq,
|
|
HL POPqq,
|
|
AF POPqq,
|
|
EI,
|
|
RETI,
|