home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP2 / LASTDRV.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-09-25  |  1.2 KB  |  44 lines

  1. ; LASTDRV.ASM -- uses only documented DOS
  2.  
  3. ; masm lastdrv;
  4. ; link lastdrv;
  5.  
  6. _STACK  segment para stack 'STACK'
  7. _STACK  ends
  8.  
  9. _DATA   segment word public 'DATA'
  10. msg     db      'LASTDRIVE='
  11. dletter db      (?)
  12.         db      0dh, 0ah, '$'
  13. _DATA   ends
  14.  
  15. _TEXT   segment word public 'CODE'
  16.  
  17.         assume cs:_TEXT, ds:_DATA, ss:_STACK
  18.  
  19. main    proc    near
  20.         mov     ax, _DATA
  21.         mov     ds, ax          ; set DS to data segment
  22.         mov     ah, 19h         ; Get Current Disk function
  23.         int     21h             ; call MS-DOS
  24.  
  25.         mov     dl, al          ; AL now holds current drive
  26.         mov     ah, 0Eh         ; Select Disk function
  27.         int     21h             ; call MS-DOS
  28.         mov     bl, al          ; LASTDRIVE in AL; save in BL
  29.         add     al, ('A' - 1)   ; convert to drive letter
  30.         mov     dletter, al     ; insert into string
  31.  
  32.         mov     dx, offset msg  ; string in DS:DX
  33.         mov     ah, 9           ; Display String function
  34.         int     21h             ; call MS-DOS
  35.  
  36.         mov     ah, 4Ch         ; Return to DOS
  37.         mov     al, bl          ; LASTDRIVE is exit code
  38.         int     21h             ; call MS-DOS
  39. main    endp
  40.  
  41. _TEXT   ends
  42.  
  43.         end main
  44.