home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn440fh.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  2.0 KB  |  41 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;       Function 44H, Subfunctions 0EH, 0FH:                 ;
  4.         ;                     IOCTL Get/Set Logical Drive Map        ;
  5.         ;                                                            ;
  6.         ;       int ioctl_drive_owner(setflag, drv_ ltr)             ;
  7.         ;           int setflag;                                     ;
  8.         ;           int drv_ltr;                                     ;
  9.         ;                                                            ;
  10.         ;       Set setflag = 1 to change drive's map, 0 to get      ;
  11.         ;       current map.                                         ;
  12.         ;                                                            ;
  13.         ;       Returns -1 for all errors, otherwise returns         ;
  14.         ;       the block device's current logical drive letter.     ;
  15.         ;                                                            ;
  16.         ;************************************************************;
  17.  
  18. cProc   ioctl_drive_owner,PUBLIC
  19. parmB   setflag
  20. parmB   drv_ltr
  21. cBegin
  22.         mov     al,setflag      ; Load setflag.
  23.         and     al,1            ; Keep only lsb.
  24.         add     al,0fh          ; AL = 0EH for get, 0FH for set.
  25.         mov     bl,drv_ltr      ; Get drive letter.
  26.         or      bl,bl           ; Leave 0 alone.
  27.         jz      ido
  28.         and     bl,not 20h      ; Convert letter to uppercase.
  29.         sub     bl,'A'-1        ; Convert to drive number: 'A' = 1,
  30.                                 ; 'B' = 2, etc.
  31. ido:
  32.         mov     bh,0
  33.         mov     ah,44h          ; Set function code.
  34.         int     21h             ; Call MS-DOS.
  35.         mov     ah,0            ; Clear high byte.
  36.         jnc     idox            ; Branch if no error.
  37.         mov     ax,-1-'A'       ; Return -1 for errors.
  38. idox:
  39.         add     ax,'A'          ; Return drive letter.
  40. cEnd
  41.