home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / buffers.lbr / BDUMP.MZC / BDUMP.MAC
Encoding:
Text File  |  1987-01-14  |  1.4 KB  |  54 lines

  1.     extrn    .getusr, .setusr, .broom, .ldem, .dos
  2.     extrn    .advance, b.cnt
  3. ;
  4. @dma    equ    26
  5. @wtseq    equ    21
  6. ;
  7. ; Write buffer hl^ until less than 128 bytes stored.
  8. ; Carry for write error.
  9. ; Reset pointers for any extra portion not written.
  10. ; Assumes no access via rdptr, i.e. output only buffer
  11. ; This code assumes buffer size to be a multiple of 128 bytes,
  12. ; so that single writes never need to "wrap around" the buffer.
  13. ; a,f
  14. .bdump::
  15.     call    .getusr
  16.     push    psw
  17.     mov    a,m
  18.     ani    01fh
  19.     call    .setusr
  20.     push b    ! push d ! push h
  21. bdump1:    inx h    ! inx h
  22.     mov c,m    ! inx h ! mov b,m;    get size
  23.     inx h    ! call .ldem;        get fcb, point to cnt
  24.     mov a,m    ! ani 080h;        check cnt
  25.     inx h    ! ora m
  26.     jz    bdumpx;            < 128 stored
  27.     mov a,d    ! ora e ! stc
  28.     jz    bdumpx;            error, no fcb
  29.     push    d;            save fcb
  30.     dcx    h
  31.     mov a,m    ! sui 128 ! mov m,a
  32.     inx    h
  33.     mov a,m    ! sbi 0 ! mov m,a;    cnt := cnt - 128
  34.     inx    h
  35.     call    .advance ! inx h;    rptr, check wrap
  36.     inx h    ! inx h ! dad d;    form access pointer
  37.     xchg
  38.     mvi    a,@dma
  39.     call    .dos;            set xfr address
  40.     pop    d
  41.     mvi    a,@wtseq
  42.     call    .dos;            write it
  43.     pop    h ! push h
  44.     stc;                in case of write error
  45.     jz    bdump1;            repeat until empty or error
  46. bdumpx:    pop h    ! pop d ! pop b
  47.     xthl;                get entry user to h
  48.     push    psw;            save any error flag
  49.     mov    a,h
  50.     call    .setusr;            restore entry user
  51.     pop    psw
  52.     pop    h
  53.     ret
  54. î