X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/40df51aed30ddcd710c7356f8098516c27088392..830b73bf0153777e6ae76ca44d64718a53b0b1b5:/cbios/conbuf.180 diff --git a/cbios/conbuf.180 b/cbios/conbuf.180 index 64d42dc..a9e1ec6 100644 --- a/cbios/conbuf.180 +++ b/cbios/conbuf.180 @@ -4,22 +4,33 @@ ; ; FIFO channels for communication with avr ; - global ff.init,ff.in,ff.ist,ff.out,ff.ost + global ff_dev + extrn ff_empty,ff_get,ff_full,ff_put extrn bufinit,fifolst include config.inc if CPU_Z180 - include z180reg.inc + maclib z180reg.inc endif - + dseg mkbuf ci.fifo_id, ci.fifo, ci.fifo_len mkbuf co.fifo_id, co.fifo, co.fifo_len ici equ ci.fifo_id * 2 ico equ co.fifo_id * 2 +;-------------------------------------------------------------- + + dseg + + dw ff.out + dw ff.ost + dw ff.in + dw ff.ist + dw ff.init +ff_dev: ;-------------------------------------------------------------- @@ -38,65 +49,33 @@ ff.init: ;-------------------------------------------------------------- ; Input status -; buffer is empty, if output index and input index are the same - cseg + dseg ff.ist: push ix ld ix,(fifolst+ici) ; - -buf.empty: - ld a,(ix+o.in_idx) ; - sub (ix+o.out_idx) ; + call ff_empty pop ix - ret z - or 0ffh ret - ;-------------------------------------------------------------- -; Output status -; buffer is full, if output index is one behind input index +; Get an input character ff.in: push ix ld ix,(fifolst+ici) ; - -buf.get: - push ix - pop hl - ld c,(ix+o.out_idx) ; - ld b,0 - add hl,bc - ld a,c -bg.wait: - cp (ix+o.in_idx) ; - jr z,bg.wait - ld b,(hl) - ld a,c ; - inc a - and (ix+o.mask) - ld (ix+o.out_idx),a - ld a,b + call ff_get pop ix ret ;-------------------------------------------------------------- ; Output status -; buffer is full, if output index is one behind input index ff.ost: push ix ld ix,(fifolst+ico) ; - -buf.full: - ld a,(ix+o.in_idx) ; - inc a - and (ix+o.mask) - sub (ix+o.out_idx) ; + call ff_full pop ix - ret z - or 0ffh ret @@ -108,28 +87,9 @@ buf.full: ff.out: push ix ; ld ix,(fifolst+ico) ; -buf.put: - push ix ; - pop hl ; get buffer start address - - ld a,c ; - ld c,(ix+o.in_idx) ; add input index - ld b,0 ; - add hl,bc ; - ld (hl),a ; one place is allways free - ld b,a ; - - ld a,c ; bump input index - inc a ; - and (ix+o.mask) ; -bp.wait: ; do - cp (ix+o.out_idx) ; - jr z,bp.wait ; while new input idx == ouput idx - ld (ix+o.in_idx),a ; - + call ff_put out (AVRINT6),a ; tell monitor - ld a,b ; pop ix ; - ret ; + ret end