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 / DISK1.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  4.7 KB  |  214 lines

  1.      page    58,132
  2. ; disk1.asm
  3. ; contains: seldsk(),diskreset(),curdsk(),gsetdta(),ggetdta(),dosparse()
  4. ;
  5.  
  6.         include    model.h
  7.         include    prologue.h
  8.         include equ.h
  9.         name    disk1
  10.         pseg    disk1
  11.  
  12. ;==>--    int seldsk(drive)
  13. ;
  14. ;;    ARGUMENTS:
  15. ;      (unsigned)    drive    -    Requested drive code: 0=A,1=B etc
  16. ;
  17. ;;    DESCRIPTION:
  18. ;      The specified disk/diskette drive is selected
  19. ;
  20. ;;    RETURNS:
  21. ;      Actual number of drives in system.
  22. ;
  23. ;;    AUTHOR:
  24. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  25. ;;;
  26.     cproc    seldsk
  27.     mov    dl,parm1_    ;get drive code to DL
  28.     mov    ah,0Eh        ;DOS function number
  29.     int    21h
  30.     xor    ah,ah
  31.     cproce
  32.  
  33. ;==>--    void diskreset(void)
  34. ;
  35. ;;    DESCRIPTION:
  36. ;      All file buffers are flushed, uses dos function call 0x0d
  37. ;
  38. ;;    SIDE EFFECTS:
  39. ;      Files changed in size but not closed are not properly
  40. ;      recorded in the disk directory
  41. ;
  42. ;;    AUTHOR:
  43. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  44. ;;;
  45.     cproc    diskreset,,diskrese
  46.     mov    ax,0D00h
  47.     int    21h
  48.     xor    ax,ax
  49.     cproce
  50.  
  51. ;==>--    int curdsk(void)
  52. ;
  53. ;;    DESCRIPTION:
  54. ;      Get the drive code for the currently selected disk.
  55. ;
  56. ;;    RETURNS:
  57. ;      Code for current default drive (0==A: 1==B: etc)
  58. ;
  59. ;;    AUTHOR:
  60. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  61. ;;;
  62.     cproc    curdsk
  63.     mov    ah,19h
  64.     int    21h
  65.     xor    ah,ah
  66.     cproce
  67.  
  68. ;==>--    void gsetdta(table)
  69. ;
  70. ;;    ARGUMENTS:
  71. ;      (struct DISKTABLE *)    table    -    points to disk table
  72. ;                table->buffer    = buffer offset, or 32 bit
  73. ;                           pointer if D or L model.
  74. ;;    DESCRIPTION:
  75. ;      The disk transfer address is set from the parameters in the
  76. ;      table structure.
  77. ;
  78. ;;    SIDE EFFECTS:
  79. ;      a new disk transfer address will be established
  80. ;
  81. ;;    AUTHOR:
  82. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  83. ;
  84. ;;    MODIFICATIONS:
  85. ;     David Nienhiser Wed 11-Jan-1989 10:53:53
  86. ;      Renamed from setdta()
  87. ;;;
  88.     cproc    gsetdta
  89.     if    _LDATA
  90.      push    ds
  91.      lds    bx,parm1_        ;get pointer to structure
  92.      lds    dx,[bx+buffer]        ;ds:dx points to buffer
  93.     else
  94.      mov    bx,parm1_        ;get ptr to structure
  95.      mov    dx,[bx+buffer]        ;ds:dx points to buffer
  96.     endif
  97.     mov    ax,1A00h        ;function number
  98.     int    21h
  99.     if    _LDATA
  100.      pop    ds
  101.     endif
  102.     xor    ax,ax            ;uniformly return 0
  103.     cproce
  104.  
  105. ;==>--    int ggetdta(table)
  106. ;
  107. ;;    ARGUMENTS:
  108. ;      (struct DISKTABLE *)    table    -    points to variable type
  109. ;                        struct DISKTABLE that receives
  110. ;                        the current DTA.
  111. ;                table->buffer    buffer offset, or 32 bit
  112. ;                        pointer if D/L model.
  113. ;;    DESCRIPTION:
  114. ;      Gets disk transfer address to DISKTABLE
  115. ;
  116. ;;    RETURNS:
  117. ;      0 if pointers are 16 bits (S/P models), or -1 if they are 32 bits
  118. ;      (D/L models).
  119. ;
  120. ;;    AUTHOR:
  121. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  122. ;
  123. ;;    MODIFICATIONS:
  124. ;     "" Wed 11-Jan-1989 10:53:53
  125. ;      Renamed from getdta().
  126. ;;;
  127.     cproc    ggetdta
  128.     push    es
  129.     mov    ah,2Fh
  130.     int    21h            ;es:bx now contains current DTA
  131.     if    _LDATA
  132.      push    ds
  133.      lds    si,parm1_        ;pointer to structure
  134.      mov    word ptr [si+buffer+2],es    ;segment
  135.      mov    word ptr [si+buffer],bx        ;offset
  136.      pop    ds
  137.      mov    ax,-1            ;indicate long pointers.
  138.     else
  139.      mov    si,parm1_        ;pointer to structure
  140.      mov    [si+buffer],bx
  141.      xor    ax,ax            ;indicate short ptrs
  142.     endif
  143.     pop    es
  144.     cproce
  145.  
  146. ;==>--    int dosparse(table)
  147. ;
  148. ;;    ARGUMENTS:
  149. ;      (struct DISKTABLE *)    table        points to DISKTABLE
  150. ;                table->string    points to filename
  151. ;
  152. ;;    DESCRIPTION:
  153. ;      The string pointed to by table->string is parsed and a drive
  154. ;      filename, and extension is placed in the FCB.
  155. ;
  156. ;;    RETURNS:
  157. ;      0 if successful, ERROR(-1) if: (a) either "?" or "*" appear in
  158. ;      filename or extension, or (b) if drive specifier is invalid, or
  159. ;      (c) if backslash is found in string.
  160. ;
  161. ;;    AUTHOR:
  162. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  163. ;
  164. ;;    MODIFICATIONS:
  165. ;
  166. ;;;
  167.     cproc    dosparse
  168.     push    es
  169.     mov    ah,19h
  170.     int    21h
  171.     inc    al
  172.     if    _LDATA
  173.      push    ds
  174.      lds    bx,parm1_    ;ds:bx points to DISKTABLE
  175.      mov    cx,ds
  176.      mov    es,cx
  177.      mov    di,bx
  178.      push    cx
  179.       lea    cx,ds:fdrive
  180.      add    di,cx            ;es:di points to unopened fcb
  181.      pop    cx
  182.      mov    es:[di],al    ;set drive code in fcb
  183.      push    ds
  184.      lds    si,[bx+string]    ;ds:si points to string to be parsed
  185.      mov    ax,2907h
  186.      int    21h
  187.      pop    ds        ;ds:bx points back to structure
  188.     else
  189.      mov    bx,parm1_    ;ds:bx points to DISKTABLE
  190.      mov    cx,ds
  191.      mov    es,cx        ;es=ds
  192.      mov    di,bx
  193.      add    di,fdrive    ;es:di points to fcb
  194.      mov    es:[di],al    ;set drive code in fcb
  195.      mov    si,[bx+string]    ;ds:si points to string to be parsed
  196.      mov    ax,2907h
  197.      int    21h
  198.     endif
  199.     cmp    al,0
  200.     jne    dosp2
  201.     cmp    byte ptr es:[di+1],' '    ;is it a blank
  202.     je    dosp2        ;if so error
  203.     xor    ax,ax        ;say successful
  204.     jmp    short dosp3
  205. dosp2:    mov    ax,-1
  206. dosp3:
  207.     if    _LDATA
  208.      pop    ds
  209.     endif
  210.     pop    es
  211.     cproce
  212.     endps
  213.     end
  214.