home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12334.ZIP / GETDRIVE.ASM < prev    next >
Assembly Source File  |  1989-03-20  |  922b  |  32 lines

  1. ;----- GetDrive.Asm - retrieves the default drive
  2.  
  3. ;Syntax -
  4. ;
  5. ;   PRINT "The current drive is "; CHR$(GetDrive%)
  6.  
  7. .286
  8. .Model Medium, BASIC
  9. .Code
  10.     Extrn DosQCurDisk:Proc   ;declare the OS/2 call as external
  11.  
  12. GetDrive Proc
  13.  
  14.     Local DriveNum:Word      ;drive number
  15.     Local DriveMap:DWord     ;logical drive map (not used here)
  16.  
  17.     Push SS                  ;push segment for DriveNumber
  18.     Lea  AX,DriveNum         ;get address
  19.     Push AX                  ;and push that
  20.     Push SS                  ;same for DriveMap segment
  21.     Lea  AX,DriveMap         ;and address
  22.     Push AX
  23.     Call DosQCurDisk         ;call OS/2
  24.  
  25.     Mov  AX,DriveNum         ;load AX with the returned drive number
  26.     Add  AX,64               ;now 1 = "A", 2 = "B", and so forth
  27.     Ret                      ;return to BASIC with the function
  28.                              ;output in AX
  29.  
  30. GetDrive Endp
  31. End
  32.