]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blobdiff - cbios/conbuf.180
ascii.180 interrupt driver for ASCI 0/1
[z180-stamp-cpm3.git] / cbios / conbuf.180
index e8dfe31f38bf6d04922571bb8c4fcf1df9407342..3c846dd1f2c876cf0be8a428bcfe9e7ff029aabb 100644 (file)
@@ -6,6 +6,7 @@
 ;\r
        global  ff.init,ff.in,ff.ist,ff.out,ff.ost\r
 \r
+       extrn   ff_empty,ff_get,ff_full,ff_put\r
        extrn   bufinit,fifolst\r
 \r
        include config.inc\r
        include z180reg.inc\r
        endif\r
 \r
-\r
-       cseg\r
-\r
-       mkbuf   co.fifo_id, co.fifo, co.fifo_len\r
+       dseg\r
        mkbuf   ci.fifo_id, ci.fifo, ci.fifo_len\r
+       mkbuf   co.fifo_id, co.fifo, co.fifo_len\r
 \r
-ico    equ     co.fifo_id * 3\r
-ici    equ     ci.fifo_id * 3\r
+ici    equ     ci.fifo_id * 2\r
+ico    equ     co.fifo_id * 2\r
 \r
 \r
 ;--------------------------------------------------------------\r
 \r
 ; Init Serial I/O for console input and output\r
 ;\r
-\r
+       dseg\r
 ff.init:\r
        ld      a,(INIDONE)\r
        cp      INIDONEVAL\r
        ret     z\r
 \r
        ld      ix,ci.fifo\r
-       ld      a,ci.fifo.mask\r
        call    bufinit\r
        ld      ix,co.fifo\r
-       ld      a,co.fifo.mask\r
        jp      bufinit\r
 \r
 ;--------------------------------------------------------------\r
+; Input status\r
 \r
+       dseg\r
 ff.ist:\r
        push    ix\r
        ld      ix,(fifolst+ici)        ;\r
-\r
-buf.empty:\r
-       ld      a,(ix+o.in_idx)         ;\r
-       sub     (ix+o.out_idx)          ;\r
+       call    ff_empty\r
        pop     ix\r
-       ret     z\r
-       or      0ffh\r
        ret\r
 \r
+;--------------------------------------------------------------\r
+; Get an input character \r
 \r
 ff.in:\r
        push    ix\r
        ld      ix,(fifolst+ici)        ;\r
-\r
-buf.get:\r
-       ld      a,(ix+o.out_idx)        ;\r
-bg.wait:\r
-       cp      (ix+o.in_idx)           ;\r
-       jr      z,bg.wait\r
-\r
-       push    hl                      ;\r
-       push    ix\r
-       pop     hl\r
-       add     a,l\r
-       ld      l,a\r
-       jr      nc,bg.nc\r
-       inc     h\r
-bg.nc:\r
-       ld      l,(hl)\r
-\r
-       ld      a,(ix+o.out_idx)        ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
-       ld      (ix+o.out_idx),a\r
-\r
-       ld      a,l\r
-       pop     hl\r
+       call    ff_get\r
        pop     ix\r
        ret\r
 \r
 ;--------------------------------------------------------------\r
+; Output status\r
 \r
 ff.ost:\r
        push    ix\r
-       ld      ix,(fifolst+ico)                ;\r
-\r
-buf.full:\r
-       ld      a,(ix+o.in_idx)         ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
-       sub     (ix+o.out_idx)          ;\r
+       ld      ix,(fifolst+ico)        ;\r
+       call    ff_full\r
        pop     ix\r
-       ret     z\r
-       or      0ffh\r
        ret\r
 \r
 \r
-       if 1\r
-ff.out:\r
-       push    ix                      ;15\r
-       ld      ix,(fifolst+ico)        ;\r
-\r
-buf.put:\r
-       push    hl                      ;11\r
-       push    bc                      ;11\r
-       push    ix                      ;15\r
-       pop     hl                      ;10\r
-       ld      a,c                     ;4\r
-       ld      c,(ix+o.in_idx)         ;19\r
-       ld      b,0                     ;7\r
-       add     hl,bc                   ;11\r
-       ld      (hl),a                  ;7\r
-       ld      b,a                     ;4\r
-\r
-       ld      a,c                     ;4\r
-       inc     a                       ;4\r
-       and     (ix+o.mask)             ;19\r
-bp.wait:\r
-       cp      (ix+o.out_idx)          ;19\r
-       jr      z,bp.wait               ;12/7\r
-       ld      (ix+o.in_idx),a         ;19\r
-\r
-       out     (AVRINT6),a             ;11\r
-       ld      a,b                     ;4\r
-       pop     bc                      ;10\r
-       pop     hl                      ;10\r
-       pop     ix                      ;14\r
-       ret                             ;10\r
-\r
-       else\r
+;--------------------------------------------------------------\r
+; put character in c in buffer\r
+; destroys hl, bc\r
+; returns output char in a\r
 \r
 ff.out:\r
-       push    ix                      ;15\r
-       ld      ix,co.fifo              ;14\r
-\r
-buf.put:\r
-       push    hl                      ;11\r
-       push    ix                      ;15\r
-       pop     hl                      ;10\r
-       ld      a,(ix+o.in_idx)         ;19\r
-       add     a,l                     ;4\r
-       ld      l,a                     ;4\r
-       jr      nc,bp.1                 ;12/7\r
-       inc     l                       ;4\r
-       ld      (hl),c                  ;7\r
-       ld      a,(ix+o.in_idx)         ;19\r
-       inc     a                       ;4\r
-       and     (ix+o.mask)             ;19\r
-bp.wait:\r
-       cp      (ix+o.out_idx)          ;19\r
-       jr      z,bp.wait               ;12/7\r
-       ld      (ix+o.in_idx),a         ;19\r
-\r
-       out     (AVRINT6),a             ;11\r
-       ld      a,c                     ;4\r
-       pop     hl                      ;10\r
-       pop     ix                      ;14\r
-       ret                             ;10             |\r
-\r
-       endif\r
-\r
-;--------------------------------------------------------------\r
+       push    ix                      ;\r
+       ld      ix,(fifolst+ico)        ;\r
+       call    ff_put\r
+       out     (AVRINT6),a             ; tell monitor\r
+       pop     ix                      ;\r
+       ret\r
 \r
        end\r
+\r