1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-21 01:18:07 +11:00
collapseos/drv/acia.z80

56 lines
1.2 KiB
Z80 Assembly
Raw Normal View History

( Save ACIA conf )
2020-04-05 01:31:22 +11:00
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. )
2020-04-05 01:31:22 +11:00
(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),
2020-04-05 01:31:22 +11:00
( is it == to ACIAR>? )
DE ACIAR> LDdd(nn),
2020-04-05 01:31:22 +11:00
( carry cleared from ANDn above )
DE SBCHLss,
JRZ, L3 FWR ( end, buffer full )
DE ADDHLss, ( restore ACIAW> )
2020-04-05 01:31:22 +11:00
( buffer not full, let's write )
ACIA_IO INAn,
(HL) A LDrr,
( advance W> )
HL INCss,
ACIAW> LD(nn)HL,
DE ACIA) @ LDdd(nn),
2020-04-05 01:31:22 +11:00
DE SUBHLss,
JRNZ, L4 FWR ( skip )
( end of buffer reached )
ACIA( @ LDHL(nn),
ACIAW> LD(nn)HL,
2020-04-05 01:31:22 +11:00
L4 FSET ( skip )
L3 FSET L2 FSET ( end )
DE POPqq,
HL POPqq,
AF POPqq,
EI,
RETI,