]> 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 75741e0ebd50bdca7488a3097df5b6f5541e68d5..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
@@ -38,65 +39,33 @@ ff.init:
 \r
 ;--------------------------------------------------------------\r
 ; Input status\r
-; buffer is empty, if output index and input index are the same\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
 ;--------------------------------------------------------------\r
-; Output status\r
-; buffer is full, if output index is one behind input index\r
+; Get an input character \r
 \r
 ff.in:\r
        push    ix\r
        ld      ix,(fifolst+ici)        ;\r
-\r
-buf.get:\r
-       push    ix\r
-       pop     hl\r
-       ld      c,(ix+o.out_idx)        ;\r
-       ld      b,0\r
-       add     hl,bc\r
-       ld      a,c\r
-bg.wait:\r
-       cp      (ix+o.in_idx)           ;\r
-       jr      z,bg.wait\r
-       ld      b,(hl)\r
-       ld      a,c                     ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
-       ld      (ix+o.out_idx),a\r
-       ld      a,b\r
+       call    ff_get\r
        pop     ix\r
        ret\r
 \r
 ;--------------------------------------------------------------\r
 ; Output status\r
-; buffer is full, if output index is one behind input index\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
+       call    ff_full\r
        pop     ix\r
-       ret     z\r
-       or      0ffh\r
        ret\r
 \r
 \r
@@ -108,28 +77,10 @@ buf.full:
 ff.out:\r
        push    ix                      ;\r
        ld      ix,(fifolst+ico)        ;\r
-buf.put:\r
-       push    ix                      ;\r
-       pop     hl                      ; get buffer start address\r
-\r
-       ld      a,c                     ;\r
-       ld      c,(ix+o.in_idx)         ; add input index\r
-       ld      b,0                     ;\r
-       add     hl,bc                   ;\r
-       ld      (hl),a                  ; one place is allways free\r
-       ld      b,a                     ;\r
-\r
-       ld      a,c                     ; bump input index\r
-       inc     a                       ;\r
-       and     (ix+o.mask)             ;\r
-bp.wait:                               ; do\r
-       cp      (ix+o.out_idx)          ;\r
-       jr      z,bp.wait               ; while new input idx == ouput idx\r
-       ld      (ix+o.in_idx),a         ;\r
-\r
+       call    ff_put\r
        out     (AVRINT6),a             ; tell monitor\r
-       ld      a,b                     ;\r
        pop     ix                      ;\r
-       ret                             ;\r
+       ret\r
 \r
        end\r
+\r