]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/commitdiff
working again.
authorLeo C <erbl259-lmu@yahoo.de>
Mon, 2 Nov 2015 15:56:18 +0000 (16:56 +0100)
committerLeo C <erbl259-lmu@yahoo.de>
Mon, 13 Jun 2016 16:21:20 +0000 (18:21 +0200)
rx status fifo. loop asci0 int till asci0 rx fifo empty

cbios/ascii.180
cbios/bioskrnl.180
cbios/fifo.180

index 54ee706e4556675e77177e9f66c70aeda06a15b1..7d6afbf1479063d9eadccce0b8a78b950c045ac0 100644 (file)
@@ -10,7 +10,8 @@
        global  as1osta,as1out\r
 \r
        extrn   as_init\r
-       extrn   ff_empty,ff_get,ff_full,ff_put,ff_cnt\r
+       extrn   ff_empty,ff_get,ff_full,ff_put\r
+       extrn   ff_puth,ff_cnt,ff_gech\r
        extrn   bufinit\r
        extrn   isv_sw\r
 \r
        dseg\r
 \r
        mkbuf   s0.rx_id, s0.inbuf, s0.rx_len\r
+       mkbuf   0,    s0.instatbuf, s0.rx_len\r
        mkbuf   s0.tx_id, s0.outbuf,s0.tx_len\r
        mkbuf   s1.rx_id, s1.inbuf, s1.rx_len\r
-       mkbuf   s1.tx_id, s1.outbuf, s1.tx_len\r
+       mkbuf   0,    s1.instatbuf, s1.rx_len\r
+       mkbuf   s1.tx_id, s1.outbuf,s1.tx_len\r
 \r
 \r
 \r
@@ -120,8 +123,9 @@ as1ista:
 as0inp:\r
        push    ix\r
        ld      ix,s0.inbuf             ;\r
-       call    ff_cnt\r
-       cp      32\r
+       call    ff_gech\r
+       ld      a,b\r
+       cp      s0.rx_len/4\r
        jr      nc,a0i_1\r
        di\r
        in0     a,(cntla0)\r
@@ -130,7 +134,7 @@ as0inp:
        ei\r
        out0    (cntla0),a\r
 a0i_1:\r
-       call    ff_get\r
+       ld      a,c\r
        pop     ix\r
        ret\r
 \r
@@ -140,7 +144,7 @@ a0i_1:
 as1inp:\r
        push    ix\r
        ld      ix,s1.inbuf             ;\r
-       call    ff_get\r
+       call    ff_gech\r
        pop     ix\r
        ret\r
 \r
@@ -172,13 +176,13 @@ as1osta:
 as0out:\r
        push    ix                      ;\r
        ld      ix,s0.outbuf            ;\r
-       call    ff_put\r
+       call    ff_puth\r
+       pop     ix                      ;\r
        di                              ;\r
        in0     c,(stat0)               ;\r
        set     TIE,c                   ;\r
        out0    (stat0),c               ;\r
        ei                              ;\r
-       pop     ix                      ;\r
        ret\r
 \r
 ;--------------------------------------------------------------\r
@@ -189,13 +193,13 @@ as0out:
 as1out:\r
        push    ix                      ;\r
        ld      ix,s1.outbuf            ;\r
-       call    ff_put\r
+       call    ff_puth\r
+       pop     ix                      ;\r
        di                              ;\r
        in0     c,(stat1)               ;\r
        set     TIE,c                   ;\r
        out0    (stat1),c               ;\r
        ei                              ;\r
-       pop     ix                      ;\r
        ret\r
 \r
 \r
@@ -205,9 +209,10 @@ as1out:
        dseg\r
 rxtxi0:\r
        push    ix\r
-rxtxi0_0:\r
+rxtxi0_loop:\r
        in0     e,(stat0)               ;receive flag set?\r
-       jp      p,rxtxi0_1              ;\r
+       jp      p,rxtxi0_1              ;RDRF == Bit 7\r
+\r
 \r
 rxi_0\r
        in0     a,(asext0)              ;todo: break detection\r
@@ -219,39 +224,41 @@ rxi_0
        res     EFR,d                   ;\r
 \r
        ld      ix,s0.inbuf             ;\r
-       ld      hl,s0.inbuf             ;\r
-       ld      c,(ix+o.in_idx)         ;-2\r
+       ld      c,(ix+o.in_idx)         ;\r
        ld      b,0\r
+       ld      hl,s0.inbuf             ;\r
        add     hl,bc\r
        in0     a,(rdr0)                ;\r
        ld      (hl),a\r
 \r
-       bit     FE,e                    ;framing error?\r
-       jr      nz,?0ri_1\r
+       ld      hl,s0.instatbuf         ;save error status\r
+       add     hl,bc\r
+       ld      (hl),e\r
+                                       ;todo: error handling and break detection\r
 \r
        ld      a,c                     ;increment buffer in pointer\r
        inc     a                       ;\r
-       and     (ix+o.mask)             ;-3\r
+       ld      b,(ix+o.mask)           ;\r
+       and     b                       ;\r
        ld      c,a\r
-       inc     hl\r
-       jr      z,$+5\r
-        ld     hl,s0.inbuf             ;\r
-       sub     (ix+o.out_idx)          ;-1\r
+\r
+       sub     (ix+o.out_idx)          ;\r
        jr      z,$+5                   ;skip if buffer is full\r
-        ld     (ix+o.in_idx),c         ;-2\r
-       jr      nc,$+6\r
-        add    (ix+o.mask)             ;-3\r
-        inc    a\r
-       cp      96\r
+        ld     (ix+o.in_idx),c         ;\r
+       jr      nc,$+3                  ;\r
+        adc    b                       ;\r
+       cp      s0.tx_len*3/4\r
        jr      c,$+4\r
         set    RTS0,d                  ;RTS inactive\r
 ?0ri_1:\r
        out0    (cntla0),d              ;\r
-       jr      rxtxi0_0\r
+       jr      rxtxi0_loop\r
+\r
 \r
 rxtxi0_1:\r
        bit     TDRE,e                  ;TX int?\r
-       jr      z,rxtxi0_e\r
+       jr      z,rxtxi0_e              ;\r
+\r
 \r
        ld      ix,s0.outbuf            ;\r
 \r
@@ -263,30 +270,30 @@ rxtxi0_1:
        ld      c,a\r
        ld      b,0\r
        add     hl,bc\r
-       ld      l,(hl)\r
-       out0    (tdr0),l                ;                       7\r
+       ld      b,(hl)\r
+       out0    (tdr0),b                ;                       7\r
 \r
        inc     a\r
        and     (ix+o.mask)\r
        ld      (ix+o.out_idx),a\r
-       jr      ?0ti_3\r
+       jr      rxtxi0_loop\r
+\r
 ?0ti_2:\r
        res     TIE,e                   ;disable tx-int\r
        out0    (stat0),e               ;                       5\r
-?0ti_3:\r
-       jr      rxtxi0_0\r
 \r
 rxtxi0_e:\r
        pop     ix\r
        ret\r
 \r
+\r
 ;------------------------------------------\r
 ; ASCI 1 Transmit/Receive interupt routines\r
 \r
        dseg\r
 rxtxi1:\r
        in0     e,(stat1)               ;receive flag set?      5\r
-       jp      p,txisv1                ;\r
+       jp      p,txi1_0                ;\r
 \r
        in0     d,(rdr1)                ;todo: break detection  9\r
        bit     FE,e                    ;framing error?\r
@@ -313,7 +320,7 @@ rxtxi1:
        out0    (cntla1),a              ;                       1\r
        ret\r
 \r
-txisv1:\r
+txi1_0:\r
        push    ix\r
        ld      ix,s1.outbuf            ;\r
 \r
index 6c8366fe120796d95f2323ef4c0fb5a734436f44..2a6349429c4294b6e0efb3a1b868091ce851671a 100644 (file)
@@ -381,12 +381,31 @@ auxin:
 conin:\r
        ld      hl,(@civec)\r
 \r
+       ;check if only one device assigned\r
+\r
+       push    hl              ; save bit vector\r
+       ld      b,0\r
+insc_0:\r
+       or      a               ; clear carry\r
+       adc     hl,hl           ; shift out next bit\r
+       jr      nc,insc_1       ;\r
+       jr      z,ci$rdy        ; single device\r
+       jr      ci$check        ;\r
+\r
+insc_1:\r
+       inc     b               ; else, next device\r
+       ld      a,h\r
+       or      l               ; see if any more devices\r
+       jr      nz,insc_0       ; no,\r
+       pop     hl\r
+\r
 in$scan:\r
        push    hl              ; save bit vector\r
        ld      b,0\r
 ci$next:\r
        xor     a               ; assume next device not ready\r
        add     hl,hl           ; shift out next bit\r
+ci$check:\r
        call    c,cist1         ; see if the device has a character\r
        jr      nz,ci$rdy       ; this device has a character\r
        inc     b               ; else, next device\r
index ebcecd9c0e473b9d80abbb4b6860e489ee7de601..290eb00531cd9c935a67b498e01fb76cb4668162 100644 (file)
@@ -1,6 +1,7 @@
 \r
        public  bufinit\r
-       public  ff_empty,ff_get,ff_full,ff_put, ff_cnt\r
+       public  ff_empty,ff_get,ff_full,ff_put\r
+       public  ff_puth,ff_cnt,ff_gech\r
 \r
        public  fifolst\r
 \r
@@ -81,6 +82,11 @@ ff_empty:
        ret\r
 \r
 ;--------------------------------------------------------------\r
+; get character from fifo\r
+; destroys hl,b\r
+;\r
+; return:\r
+;      c,a: next character\r
 \r
 ff_get:\r
        push    ix\r
@@ -92,22 +98,58 @@ ff_get:
 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      c,(hl)\r
        ld      (ix+o.out_idx),a\r
-       ld      a,b\r
+       ld      a,c\r
+       ret\r
+\r
+;--------------------------------------------------------------\r
+; get character and ramaining count from fifo\r
+; halt cpu, while buffer is empty\r
+; destroys hl\r
+;\r
+; return:\r
+;      c,a: next character\r
+;      b:   number of charachters in fifo\r
+\r
+ff_gech:\r
+       push    ix\r
+       pop     hl\r
+       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
+       dec     a\r
+       ld      b,a\r
+       ld      a,c\r
+       inc     a\r
+       and     (ix+o.mask)\r
+       ld      c,(hl)\r
+       ld      (ix+o.out_idx),a\r
+       ld      a,c\r
        ret\r
 \r
 ;--------------------------------------------------------------\r
 ; Check if room in fifo\r
 ; buffer is full, if output index is one behind input index\r
+;\r
+; return\r
+;   a = 0 and z    if buffer full\r
+;   a = ff and nz  if buffer not full\r
 \r
 ff_full:\r
        ld      a,(ix+o.in_idx)         ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
+       inc     a                       ;\r
+       and     (ix+o.mask)             ;\r
        sub     (ix+o.out_idx)          ;\r
        ret     z\r
        or      0ffh\r
@@ -140,6 +182,35 @@ bp.wait:                           ; do
        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
+\r
+ff_puth:\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
+       jr      $+3\r
+bph.wait:                              ; do\r
+       halt                            ;   halt cpu\r
+       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
 ; Return number of characters in fifo\r
 ;\r
@@ -148,9 +219,9 @@ ff_cnt:
        ld      a,(ix+o.in_idx)         ;\r
        sub     (ix+o.out_idx)          ;\r
        ret     nc\r
-       add     (ix+o.mask)\r
-       inc     a\r
+       adc     (ix+o.mask)             ; mask+carry == buffer size\r
        ret\r
 \r
+;--------------------------------------------------------------\r
 \r
        end\r