home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG008.ARK / DISKIN.LIB < prev    next >
Text File  |  1984-04-29  |  1KB  |  61 lines

  1.  
  2. ;++++++++++++++++++++++++++++++++++++++++++++++
  3. ;
  4. ; SEQUENTIAL DISK CHARACTER INPUT
  5. ;
  6. ; DISKIN.LIB  -  Version 1.0  -  18 SEP 77
  7. ;
  8. ; J.W. SHOOK, P.O. BOX 185, ROCKY POINT, NY 11778
  9. ;
  10. ;++++++++++++++++++++++++++++++++++++++++++++++
  11.  
  12. ; Before reading a file sequentially 
  13. ; the following initial conditions
  14. ; must be established.
  15.  
  16. ;    1) A CP/M file control block
  17. ;       containing the file name must
  18. ;       start at location INFCB.
  19. ;    2) A 128 byte buffer area must
  20. ;       start at location INBUF.
  21. ;    3) The file must be successfully
  22. ;       opened.
  23. ;    4) The next record pointer in
  24. ;       the file control block must be
  25. ;       set to zero.
  26. ;    5) The word at location INPTR
  27. ;       must be set to INBUF+128 to
  28. ;       mark the buffer as empty.
  29. ;    6) To read a file again, just set
  30. ;       next record to zero, and
  31. ;       reset INPTR.
  32.  
  33. ; READ CHARACTER FROM FILE
  34.  
  35. DISKIN:    LHLD    INPTR    ; Test buffer pointer
  36.     LXI    D,-(INBUF+128)
  37.     DAD    D
  38.     MOV    A,H
  39.     ORA    L
  40.     CZ    RDREC    ; If empty, read next record
  41.     RC        ; Return on bad read
  42.     LHLD    INPTR    ; Get char from buffer
  43.     MOV    A,M
  44.     INX    H    ; Move buffer pointer
  45.     SHLD    INPTR
  46.     RET
  47.  
  48.  
  49. ; REFILL DISK INPUT BUFFER
  50.  
  51. RDREC:    LXI    D,INBUF    ; Set DMA address
  52.     MVI    C,SDMA
  53.     CALL    BDOS
  54.     LXI    D,INFCB    ; Read a record
  55.     MVI    C,READ
  56.     CALL    BDOS
  57.     RAR        ; Set carry on bad read
  58.     LXI    H,INBUF    ; Set pointer to buffer start
  59.     SHLD    INPTR
  60.     RET
  61.