home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / DOSRANDO.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  4.7 KB  |  172 lines

  1.         page    58,132
  2.  
  3. ; dosrando.asm
  4. ; contains: dosrdrrec(),doswtrrec(),dosrdrblk(),doswtrblk()
  5. ;
  6. ;
  7. ; MODIFICATIONS
  8. ;
  9.         include    model.h
  10.         include    prologue.h
  11.         include equ.h
  12.         name    dosrando
  13.         pseg    dosrando
  14.  
  15. ;==>--    int dosrdrrec(table)
  16. ;
  17. ;;    ARGUMENTS:
  18. ;      (struct DISKTABLE *)    table     -    points to disktable structure
  19. ;
  20. ;;    DESCRIPTION:
  21. ;      Read a random record in a file.  The record number is taken from
  22. ;      the random record field table.dskfcb.fcbrec and its length
  23. ;      is determined from the table.dskfcb.lrs field.  Data is read
  24. ;      to the current disk transfer address.
  25. ;
  26. ;;    RETURNS:
  27. ;      0 if successful, 1 if EOF on read, or if disk full on write and
  28. ;      no data is written.  2 if there is insufficient space in the DTA
  29. ;      segment to read or write the specified data, 3) if EOF on read
  30. ;      and the record is a partial record;
  31. ;
  32. ;;    AUTHOR:
  33. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  34. ;;;
  35.     cproc    dosrdrrec,,dosrdrre
  36.     if    _LDATA
  37.      push    ds
  38.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  39.     else
  40.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  41.     endif
  42.     add    dx,fcb            ;ds:dx points to FCB
  43.     mov    bx,dx
  44.     mov    byte ptr[bx],0ffh
  45.     mov    ah,21h            ;dos random read function
  46.     int    21h
  47.     if    _LDATA
  48.      pop    ds
  49.     endif
  50.     xor    ah,ah            ;return error code in AL
  51.     cproce
  52.  
  53. ;==>--    int doswtrrec(table)
  54. ;
  55. ;;    ARGUMENTS:
  56. ;      (struct DISKTABLE *)    table    -  points to DISKTABLE
  57. ;
  58. ;;    DESCRIPTION:
  59. ;      Functions exactly as dosrdrrec except writes instead of reads
  60. ;
  61. ;;    RETURNS:
  62. ;      0=write successful, 1=diskette full, 2=DTA too small
  63. ;
  64. ;;    AUTHOR:
  65. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  66. ;;;
  67.     cproc    doswtrrec,,doswtrre
  68.     if    _LDATA
  69.      push    ds
  70.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  71.     else
  72.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  73.     endif
  74.     add    dx,fcb            ;ds:dx points to FCB
  75.     mov    bx,dx
  76.     mov    byte ptr[bx],0ffh
  77.     mov    ah,22h            ;dos random write function
  78.     int    21h
  79.     if    _LDATA
  80.      pop    ds
  81.     endif
  82.     xor    ah,ah            ;return error code in AL
  83.     cproce
  84.  
  85. ;==>--    int dosrdrblk(table)
  86. ;
  87. ;;    ARGUMENTS:
  88. ;      (struct DISKTABLE *)    table    -  points to DISKTABLE structure
  89. ;
  90. ;;    DESCRIPTION:
  91. ;      Dos random read block.  Read one or more random records in a
  92. ;      file.  The record number of the first record to be read is taken
  93. ;      from the random record field (table.dskfcb.fcbrec) and its
  94. ;      length is specified by table.dskfcb.lrs on entry.  The number
  95. ;      of records to be read in this sequence at this position is
  96. ;      specified by tbl.rbytes on entry.  Data is read to the disk
  97. ;      transfer address (DTA) (previously set).  The file attribute
  98. ;      must be specified in table.dskfcb.dskattr.fattr on entry
  99. ;      and will be used.
  100. ;
  101. ;;    RETURNS:
  102. ;      0=successful, 1=end of file, 2=insufficient space in DTA segment
  103. ;      3=If EOF ( a partial record was read and filled out with zeros)
  104. ;
  105. ;;    AUTHOR:
  106. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  107. ;;;
  108.     cproc    dosrdrblk,,dosrdrbl
  109.     if    _LDATA
  110.      push    ds
  111.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  112.     else
  113.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  114.     endif
  115.     add    dx,fcb            ;ds:dx points to FCB
  116.     mov    bx,dx
  117.     mov    byte ptr[bx],0ffh
  118.     mov    cx,[bx+rbytes]        ;Number of records to read
  119.     mov    ah,27h            ;dos random write function
  120.     int    21h
  121.     if    _LDATA
  122.      pop    ds
  123.     endif
  124.     mov    [bx+abytes],cx        ;save number of bytes read
  125.     xor    ah,ah            ;return error code in AL
  126.     cproce
  127.  
  128. ;==>--    int doswtrblk(table)
  129. ;
  130. ;;    ARGUMENTS:
  131. ;      (struct DISKTABLE *)    table    -  points to DISKTABLE structure
  132. ;
  133. ;;    DESCRIPTION:
  134. ;      Dos random write block.  Write one or more random records in a
  135. ;      file.  The record number of the first record to be written is taken
  136. ;      from the random record field (table.dskfcb.fcbrec) and its
  137. ;      length is specified by table.dskfcb.lrs on entry.  The number
  138. ;      of records to be written in this sequence at this position is
  139. ;      specified by tbl.rbytes on entry.  Data is written from the disk
  140. ;      transfer address (DTA) (previously set).  The file attribute
  141. ;      must be specified in table.dskfcb.dskattr.fattr on entry
  142. ;      and will be used.
  143. ;
  144. ;;    RETURNS:
  145. ;      0=successful, 1=end of file, 2=insufficient space in DTA segment
  146. ;      3=If EOF ( a partial record was read and filled out with zeros)
  147. ;
  148. ;;    AUTHOR:
  149. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  150. ;;;
  151.     cproc    doswtrblk,,doswtrbl
  152.     if    _LDATA
  153.      push    ds
  154.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  155.     else
  156.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  157.     endif
  158.     add    dx,fcb            ;ds:dx points to FCB
  159.     mov    bx,dx
  160.     mov    byte ptr[bx],0ffh
  161.     mov    cx,[bx+rbytes]        ;Number of records to read
  162.     mov    ah,28h            ;dos random write function
  163.     int    21h
  164.     if    _LDATA
  165.      pop    ds
  166.     endif
  167.     mov    [bx+abytes],cx        ;save number of bytes read
  168.     xor    ah,ah            ;return error code in AL
  169.     cproce
  170.     endps
  171.     end
  172.