home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff339.lzh / PCQ / Runtime.lzh / Runtime / Readers / fileptr.asm next >
Assembly Source File  |  1989-11-20  |  922b  |  36 lines

  1. *
  2. *    FilePtr.asm (of the PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4. *
  5. *    This routine is called whenever a file pointer is used in
  6. *    the main program.  One might expect that we could simply
  7. *    refer to the CURRENT pointer in the file structure, but
  8. *    if the file is INTERACTIVE (which would not be known until
  9. *    runtime), we might have to do a read first.
  10. *
  11. *    On entry, a0 holds the address of the file record
  12. *
  13.  
  14.     INCLUDE    ":runtime/FileRec.i"
  15.  
  16.     XREF    _p%FillBuffer
  17.     XREF    _p%IOResult
  18.  
  19.     SECTION    FilePtr,CODE
  20.  
  21.     XDEF    _p%FilePtr
  22. _p%FilePtr
  23.  
  24.     tst.l    _p%IOResult        ; is IO system OK?
  25.     bne    1$
  26.     tst.b    INTERACTIVE(a0)        ; if not interactive, never mind
  27.     beq.s    1$            ; leave now
  28.     move.l    CURRENT(a0),a1        ; get the current position
  29.     cmpa.l    LAST(a0),a1        ; are we at end?
  30.     blt.s    1$            ; if not empty, skip
  31.     jsr    _p%FillBuffer        ; otherwise, fill buffer
  32. 1$    move.l    CURRENT(a0),a0        ; get the current ptr
  33.     rts                ; and return
  34.  
  35.     END
  36.