]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blobdiff - cbios/fifo.180
Update IXON flag from character device table (@ctbl)
[z180-stamp-cpm3.git] / cbios / fifo.180
index 290eb00531cd9c935a67b498e01fb76cb4668162..ded979a6db09cec39402a565fe16b22c5bafce48 100644 (file)
@@ -7,8 +7,8 @@
 \r
        extrn   msg.sm,hwl2phy\r
 \r
-       include config.inc\r
-       include z180reg.inc\r
+       maclib z180reg.inc\r
+       maclib config.inc\r
 \r
 \r
 ;--------------------------------------------------------------------\r
@@ -120,14 +120,14 @@ ff_gech:
        ld      c,(ix+o.out_idx)        ;\r
        ld      b,0\r
        add     hl,bc\r
-       jr      $+3\r
 gech.wait:\r
-       halt\r
        ld      a,(ix+o.in_idx)         ;\r
        sub     c\r
-       jr      z,gech.wait\r
-       jr      nc,$+5\r
-        adc    (ix+o.mask)             ; mask+carry == buffer size\r
+       jr      nz,gech.cont\r
+       halt\r
+       jr      gech.wait\r
+gech.cont:\r
+       and     (ix+o.mask)             ;\r
        dec     a\r
        ld      b,a\r
        ld      a,c\r
@@ -158,19 +158,18 @@ ff_full:
 \r
 ;--------------------------------------------------------------\r
 ; put character in c in buffer\r
-; destroys hl, bc\r
-; returns output char in a\r
+; destroys bc\r
 \r
 ff_put:\r
        push    ix                      ;\r
-       pop     hl                      ; get buffer start address\r
+       ex      (sp),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
+       pop     hl                      ; restore hl\r
 \r
        ld      a,c                     ; bump input index\r
        inc     a                       ;\r
@@ -179,25 +178,23 @@ bp.wait:                          ; do
        cp      (ix+o.out_idx)          ;\r
        jr      z,bp.wait               ; while new input idx == ouput idx\r
        ld      (ix+o.in_idx),a         ;\r
-       ld      a,b                     ;\r
        ret                             ;\r
 \r
 ;--------------------------------------------------------------\r
 ; put character in c in buffer\r
 ; halt cpu, while buffer is is full\r
-; destroys hl, bc\r
-; returns output char in a\r
+; destroys bc\r
 \r
 ff_puth:\r
        push    ix                      ;\r
-       pop     hl                      ; get buffer start address\r
+       ex      (sp),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
+       pop     hl                      ; restore hl\r
 \r
        ld      a,c                     ; bump input index\r
        inc     a                       ;\r
@@ -208,7 +205,6 @@ bph.wait:                           ; do
        cp      (ix+o.out_idx)          ;\r
        jr      z,bph.wait              ; while new input idx == ouput idx\r
        ld      (ix+o.in_idx),a         ;\r
-       ld      a,b                     ;\r
        ret                             ;\r
 \r
 ;--------------------------------------------------------------\r
@@ -218,8 +214,7 @@ bph.wait:                           ; do
 ff_cnt:\r
        ld      a,(ix+o.in_idx)         ;\r
        sub     (ix+o.out_idx)          ;\r
-       ret     nc\r
-       adc     (ix+o.mask)             ; mask+carry == buffer size\r
+       and     (ix+o.mask)             ;\r
        ret\r
 \r
 ;--------------------------------------------------------------\r