home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 223_02 / grabio.mac < prev    next >
Text File  |  1989-02-23  |  1KB  |  42 lines

  1. ;
  2. ;    grabio()    by    F.A.Scacchitti        9/18/84
  3. ;
  4. ;    find an    input buffer, and return its address.
  5. ;    if there isn't one, return a NULL.
  6. ;
  7.  
  8. ;
  9. NBUFS    EQU    8
  10. FCBSIZE    EQU    36    ;size, in bytes, of an FCB
  11. BUFFER    EQU    6    ;offset    to disk    sector buffer in I/O structure
  12. FLAG    EQU    33    ;file-type flag    byte (in unused    part of    FCB)
  13. FREEFLG    EQU    128    ;This I/O structure is available for the taking
  14. BUFSIZ    EQU    1024    ;how long the sector buffer is
  15. NULL    EQU    0
  16. TBUFSZ  EQU    128    ; Default buffer size
  17. ;
  18.  
  19. EXTRN    ZZBUF
  20. ;
  21. GRABIO::                            ;6 May 80 rj
  22.     MVI    B,NBUFS
  23.     LXI    H,ZZBUF+TBUFSZ+FLAG
  24.     LXI    D,FCBSIZE+BUFFER+BUFSIZ
  25.     MVI    A,FREEFLG
  26. GRAB2:    CMP    M            ;flag byte == freeflg?
  27.     JZ    GRAB3            ;if so,    found a    free buffer
  28.     DAD    D            ;on to next buffer
  29.     DCR    B
  30.     JNZ    GRAB2            ;if there is one...
  31.     LXI    H,NULL            ;there ain't
  32.     RET                ;give up
  33. ;
  34. GRAB3:    MVI    M,0            ;mark buffer as    taken
  35.     LXI    D,-FLAG            ;back up to buffer start
  36.     DAD    D    
  37.     RET                ;and hand it back
  38.  
  39. ;
  40.     END
  41.  
  42.