summaryrefslogtreecommitdiff
path: root/z180/conbuf-a.180
diff options
context:
space:
mode:
authorLeo C2014-10-23 02:22:01 +0200
committerLeo C2014-10-23 02:22:01 +0200
commit6a4e9540b950d871ea8fa072b195490a231b251d (patch)
tree2078c1bcf0abe120c28f0e0f9a1404162bb29c85 /z180/conbuf-a.180
parent424b184a9bab3b1b8fe93fbc9e8a6e9d566904c8 (diff)
downloadz180-stamp-6a4e9540b950d871ea8fa072b195490a231b251d.zip
new fifos msg in, msg out, console in, console out
Diffstat (limited to 'z180/conbuf-a.180')
-rw-r--r--z180/conbuf-a.180130
1 files changed, 130 insertions, 0 deletions
diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180
new file mode 100644
index 0000000..3ec84d4
--- /dev/null
+++ b/z180/conbuf-a.180
@@ -0,0 +1,130 @@
+ page 255
+ .z80
+
+;
+; FIFO channels for communication with avr
+;
+ global ff.init,ff.in,ff.out,ff.i.st
+
+ extrn buf.init
+
+ include config.inc
+ include z180reg.inc
+
+
+;--------------------------------------------------------------
+
+ dseg
+
+
+ mkbuf co.fifo,co.fifo_len
+ mkbuf ci.fifo,ci.fifo_len
+
+
+;--------------------------------------------------------------
+
+ cseg
+
+; Init Serial I/O for console input and output
+;
+
+ff.init:
+ ld ix,ci.fifo
+ ld a,ci.fifo.mask
+ call buf.init
+ ld ix,co.fifo
+ ld a,co.fifo.mask
+ jp buf.init
+
+
+ff.i.st:
+ push ix
+ ld ix,ci.fifo ;
+
+buf.empty:
+ ld a,(ix+o.in_idx) ;
+ sub (ix+o.out_idx) ;
+ pop ix
+ ret z
+ or 0ffh
+ ret
+
+
+ff.in:
+ push ix
+ ld ix,ci.fifo ;
+
+buf.get:
+ ld a,(ix+o.out_idx) ;
+bg.wait:
+ cp (ix+o.in_idx) ;
+ jr z,bg.wait
+
+ push hl ;
+ push ix
+ pop hl
+ add a,l
+ ld l,a
+ jr nc,bg.nc
+ inc h
+bg.nc:
+ ld l,(hl)
+
+ ld a,(ix+o.out_idx) ;
+ inc a
+ and (ix+o.mask)
+ ld (ix+o.out_idx),a
+
+ ld a,l
+ pop hl
+ pop ix
+ ret
+
+
+ff.o.st:
+ push ix
+ ld ix,co.fifo ;
+
+buf.full:
+ ld a,(ix+o.in_idx) ;
+ inc a
+ and (ix+o.mask)
+ sub (ix+o.out_idx) ;
+ pop ix
+ ret z
+ or 0ffh
+ ret
+
+
+ff.out:
+ push ix
+ ld ix,co.fifo ;
+
+buf.put:
+ push hl ;
+ push bc
+ push ix
+ pop hl
+ ld c,(ix+o.in_idx) ;
+ ld b,0
+ add hl,bc
+ ld b,a
+
+ ld a,c ;
+ inc a
+ and (ix+o.mask)
+bp.wait:
+ cp (ix+o.out_idx) ;
+ jr z,bp.wait
+ ld (hl),b
+ ld (ix+o.in_idx),a
+
+ out (AVRINT6),a
+ ld a,b
+ pop bc
+ pop hl
+ pop ix
+ ret
+
+ end
+