]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blobdiff - cbios/fifo.180
ff_put/ff_puth: preserve hl, don't return output char
[z180-stamp-cpm3.git] / cbios / fifo.180
index e818c5a7cfa39814297018cc80d0cf4dbf278173..e1bda54bd4ab69d9ce55e005a78795e164dfacee 100644 (file)
@@ -159,19 +159,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
@@ -180,25 +179,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
@@ -209,7 +206,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