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 / DOS1FUN.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  7.1 KB  |  320 lines

  1.         page    58,132
  2. ; dos1fun.asm
  3. ; contains: dos1read(),dos1write(),dos1open(),dos1close(),dos1create()
  4. ; contains: dos1delete(),dos1append(),dos1rename()
  5. ;
  6. ;
  7. ; MODIFICATIONS
  8. ;
  9.         include    model.h
  10.         include    prologue.h
  11.         include equ.h
  12.  
  13.         name    dos1fun
  14.         dseg    dos1fu
  15. temp        db    135 dup (0)
  16.         endds
  17.         pseg    dos1fun
  18.  
  19. ;==>--    int dos1read(table)
  20. ;
  21. ;;    ARGUMENTS:
  22. ;      (struct DISKTABLE *)    table   -  Points to disk table
  23. ;
  24. ;;    DESCRIPTION:
  25. ;      Read sequentially the record addressed by the current block
  26. ;      table->dskfcb.blocknum and current record table->dskfcb.fcbcr
  27. ;      elements of the FCB into the current DTA (disk transfer address)
  28. ;
  29. ;;    RETURNS:
  30. ;      0= read was successful, 1=EOF (no data read), 2=DTA too small
  31. ;      3= EOF (a partial record was read)
  32. ;
  33. ;;    AUTHOR:
  34. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  35. ;;;
  36.     cproc    dos1read
  37.     if    _LDATA
  38.      push    ds
  39.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  40.     else
  41.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  42.     endif
  43.     add    dx,fcb            ;ds:dx points to FCB
  44.     mov    bx,dx
  45.     mov    byte ptr [bx],0ffh    ;make extended fcb
  46.     mov    ah,14h            ;ms-dos sequential read function
  47.     int    21h
  48.     if    _LDATA
  49.      pop    ds
  50.     endif
  51.     xor    ah,ah            ;return any errors in al
  52.     cproce
  53.  
  54. ;==>--    int dos1write(table)
  55. ;
  56. ;;    ARGUMENTS:
  57. ;      (struct DISKTABLE *)    table   -  Points to disk table
  58. ;
  59. ;;    DESCRIPTION:
  60. ;      Write sequentially the record addressed by the current block
  61. ;      table->dskfcb.blocknum and current record table->dskfcb.fcbcr
  62. ;      elements of the FCB from the current DTA (disk transfer address)
  63. ;
  64. ;;    RETURNS:
  65. ;      0= write was successful, 1=diskette full, 2=DTA too small
  66. ;
  67. ;;    AUTHOR:
  68. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  69. ;;;
  70.     cproc    dos1write,,dos1writ
  71.     if    _LDATA
  72.      push    ds
  73.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  74.     else
  75.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  76.     endif
  77.     add    dx,fcb            ;ds:dx points to FCB
  78.     mov    bx,dx
  79.     mov    byte ptr [bx],0ffh    ;make extended fcb
  80.     mov    ah,15h            ;ms-dos sequential write function
  81.     int    21h
  82.     if    _LDATA
  83.      pop    ds
  84.     endif
  85.     xor    ah,ah            ;return any errors in al
  86.     cproce
  87.  
  88. ;==>--    unsigned dos1open(table)
  89. ;
  90. ;;    ARGUMENTS:
  91. ;      (struct DISKTABLE *)    table   -  Pointer to DISKTABLE
  92. ;
  93. ;;    DESCRIPTION:
  94. ;      Dos 1.x open file.  The FCB portion of the structure must contain
  95. ;      a filename and drive code.  The directory is checked, and if the
  96. ;      file exists it is opened.
  97. ;
  98. ;;    RETURNS:
  99. ;      0==Successful (file found), 0xFF = if Unsuccessful (not found)
  100. ;
  101. ;;    AUTHOR:
  102. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  103. ;;;
  104.     cproc    dos1open
  105.     if    _LDATA
  106.      push    ds
  107.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  108.     else
  109.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  110.     endif
  111.     add    dx,fcb            ;ds:dx points to FCB
  112.     mov    bx,dx
  113.     mov    byte ptr [bx],0ffh    ;make extended fcb
  114.     mov    ah,0fh            ;ms-dos open file function
  115.     int    21h
  116.     if    _LDATA
  117.      pop    ds
  118.     endif
  119.     xor    ah,ah            ;return any errors in al
  120.     cproce
  121.  
  122. ;==>--    unsigned dos1close(table)
  123. ;
  124. ;;    ARGUMENTS:
  125. ;      (struct DISKTABLE *)    table    -    
  126. ;
  127. ;;    DESCRIPTION:
  128. ;      DOS 1.x file close
  129. ;
  130. ;;    RETURNS:
  131. ;      00=successful, FF=File not found (unsuccessful)
  132. ;
  133. ;;    AUTHOR:
  134. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  135. ;;;
  136.     cproc    dos1close,,dos1clos
  137.     if    _LDATA
  138.      push    ds
  139.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  140.     else
  141.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  142.     endif
  143.     add    dx,fcb            ;ds:dx points to X-FCB
  144.     mov    bx,dx
  145.     mov    byte ptr [bx],0ffh    ;make extended fcb
  146.     mov    ah,10h            ;ms-dos close file function
  147.     int    21h
  148.     if    _LDATA
  149.      pop    ds
  150.     endif
  151.     xor    ah,ah            ;return any errors in al
  152.     cproce
  153.  
  154. ;==>--    unsigned dos1create(table)
  155. ;
  156. ;;    ARGUMENTS:
  157. ;      (struct DISKTABLE *)    table    -  points to DISKTABLE structure
  158. ;
  159. ;;    DESCRIPTION:
  160. ;      DOS 1.x file create
  161. ;
  162. ;;    RETURNS:
  163. ;      Normally if successful 00, if no directory space exists
  164. ;      return 0xFF.
  165. ;
  166. ;;    AUTHOR:
  167. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  168. ;;;
  169.     cproc    dos1create,,dos1crea,
  170.     if    _LDATA
  171.      push    ds
  172.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  173.     else
  174.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  175.     endif
  176.     add    dx,fcb            ;ds:dx points to X-FCB
  177.     mov    bx,dx
  178.     mov    byte ptr [bx],0ffh    ;make extended fcb
  179.     mov    ah,16h            ;ms-dos file create function
  180.     int    21h
  181.     if    _LDATA
  182.      pop    ds
  183.     endif
  184.     xor    ah,ah            ;return any errors in al
  185.     cproce
  186.  
  187. ;==>--    unsigned dos1delete(table)
  188. ;
  189. ;;    ARGUMENTS:
  190. ;      (struct DISKTABLE *)    table  -  points to DISKTABLE structure
  191. ;
  192. ;;    DESCRIPTION:
  193. ;      DOS 1.x  file delete
  194. ;
  195. ;;    RETURNS:
  196. ;      00 if successful, 0xff if directory entry match was not found
  197. ;
  198. ;;    AUTHOR:
  199. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  200. ;;;
  201.     cproc    dos1delete,,dos1dele
  202.     if    _LDATA
  203.      push    ds
  204.      lds    dx,parm1_        ;ds:dx points to DISKTABLE
  205.     else
  206.      mov    dx,parm1_        ;ds:dx points to DISKTABLE
  207.     endif
  208.     add    dx,fcb            ;ds:dx points to X-FCB
  209.     mov    bx,dx
  210.     mov    byte ptr [bx],0ffh    ;make extended fcb
  211.     mov    ah,13h            ;ms-dos file delete function
  212.     int    21h
  213.     if    _LDATA
  214.      pop    ds
  215.     endif
  216.     xor    ah,ah            ;return any errors in al
  217.     cproce
  218.  
  219. ;==>--    unsigned dos1append(table)
  220. ;
  221. ;;    ARGUMENTS:
  222. ;      (struct DISKTABLE *)    table  -  points to DISKTABLE structure
  223. ;
  224. ;;    DESCRIPTION:
  225. ;      Sets FCB parameters so that the random record number fcbrec is
  226. ;      at the first byte past the end of file.
  227. ;
  228. ;;    RETURNS:
  229. ;      0 normally, 0xff if file not found
  230. ;
  231. ;;    AUTHOR:
  232. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  233. ;;;
  234.     cproc    dos1append,,dos1appe
  235.     if    _LDATA
  236.      push    ds
  237.      lds    bx,parm1_        ;ds:bx points to DISKTABLE
  238.     else
  239.      mov    bx,parm1_        ;ds:bx points to DISKTABLE
  240.     endif
  241.     mov    bx,dx
  242.     add    dx,fcb            ;ds:dxpoint to X-FCB
  243.     mov    [bx+fcb],0ffh        ;make extended FCB
  244.     mov    [bx+lrs],1        ;record size = 1 byte
  245.     mov    ah,23h            ;determine file size
  246.     int    21h
  247.     if    _LDATA
  248.      pop    ds
  249.     endif
  250.     or    al,al            ;check for error
  251.     jnz    do1apex            ;if error exit
  252.     add    [bx+fcbrec],1        ;increment lo-order part
  253.     adc    [bx+_fcbr2],0        ;adjust hi=order part
  254. do1apex:xor    ah,ah
  255.     cproce
  256.     
  257. ;==>--    unsigned dos1rename(from,to)
  258. ;
  259. ;;    ARGUMENTS:
  260. ;      (struct DISKTABLE *)    from    -  existing filename
  261. ;      (struct DISKTABLE *)  to    -  new filename
  262. ;
  263. ;;    DESCRIPTION:
  264. ;      DOS 1.x Rename file
  265. ;
  266. ;;    RETURNS:
  267. ;      00 normally success, 0xFF from file does not exist
  268. ;
  269. ;;    AUTHOR:
  270. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  271. ;;;
  272.     cproc    dos1rename,,dos1rena,
  273.     if    _LDATA
  274.      push    es
  275.      les    si,parm1_        ;es:si = parm1_
  276.     else
  277.      mov    si,parm1_
  278.     endif
  279.     add    si,fdrive
  280.     lea    bx,temp            ;bx points to temporary fcb
  281.     mov    cx,6            ;move 6 words (12 bytes)
  282. d1rlp1:    
  283.     if    _LDATA
  284.      mov    ax,es:[si]
  285.     else
  286.      mov    ax,[si]
  287.     endif
  288.     mov    [bx],ax
  289.     add    bx,2
  290.     add    si,2
  291.     loop    d1rlp1
  292.     add    bx,4            ;ds:bx points to next area
  293.     if    _LDATA
  294.      les    si,parm2_
  295.     else
  296.      mov    si,parm2_
  297.     endif
  298.     add    si,fname
  299.     mov    cx,11            ;move 11 bytes
  300. dlrlp2:
  301.     if    _LDATA
  302.      mov    al,es:[si]
  303.     else
  304.      mov    al,[si]
  305.     endif
  306.     mov    [bx],al            ;save in temp
  307.     inc    si
  308.     inc    bx
  309.     loop    dlrlp2            ;move file name to temp area
  310.     if    _LDATA
  311.      pop    es
  312.     endif
  313.     lea    dx,temp            ;ds:dx points to temporary area
  314.     mov    ah,17h            ;dos rename function
  315.     int    21h
  316.     xor    ah,ah            ;return error in al
  317.     cproce
  318.     endps
  319.     end
  320.