home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / XP.ZIP / DRIVE.ASM next >
Encoding:
Assembly Source File  |  1989-12-20  |  1.6 KB  |  57 lines

  1. ; Function to find the existance of a drive.
  2. ; int drivePresent(int drive)
  3. ;       drive : 0 = A, 1 = B, 2 = C etc...
  4. ; Returns:
  5. ;       0   - drive not present
  6. ;       40h (64) - logical/physical drive
  7. ;       50h (80) - SUBST drive
  8. ; For Turbo C 2.0, small/tiny model.
  9. ; Written and tested with Turbo Assembler 1.0
  10. ; By Goh King Hwa, 20 Dec 1989.
  11.  
  12. LASTDRIVE       EQU     33
  13. DPATH           EQU     22
  14. PATHSIZE        EQU     81
  15. DFLAG           EQU     68
  16.  
  17. _TEXT   segment byte public 'CODE'
  18.         assume cs:_TEXT
  19.  
  20. _drivePresent   proc    near
  21.     push    bp
  22.     mov    bp,sp
  23.         mov     ah,52h          ;DOS get list of lists
  24.         int     21h
  25.         xor     ax,ax           ;zero AX
  26.         mov     cx,[bp+4]       ;get the drive specified
  27.         cmp     cl,es:[bx+LASTDRIVE]    ;check to see if it's too big
  28.         jb      Check
  29. NoDrive:
  30.         jmp     short exitFunc  ;exit, if so
  31. Check:
  32.         push    ds
  33.         push    si
  34.  
  35.         lds     si,es:[bx+DPATH]        ;get the address for path table
  36.         jcxz    done                    ;if CX zero, drive found
  37. findDrive:
  38.         add     si,PATHSIZE             ;next entry
  39.         jnc     doLoop                  ;did we overshoot one segment?
  40.         mov     dx,ds
  41.         add     dx,1000h                ;adjust to next segment
  42.         mov     ds,dx
  43. doLoop:
  44.         loop    findDrive
  45. done:
  46.         mov     al,[si+DFLAG]           ;get the current drive flag
  47.         pop     si
  48.         pop     ds
  49. exitFunc:
  50.     pop    bp
  51.     ret    
  52. _drivePresent    endp
  53. _TEXT    ends
  54.  
  55.         public  _drivePresent
  56.     end
  57.