INT 21h AH=19h returns the current drive in AL, counted from 0: A = 0, B = 1, C = 2. It cannot fail and changes nothing else. Adding the character "A" (41h) turns the number into its letter:
MOV DX, OFFSET MSG1MOV AH, 09hINT 21hMOV AH, 19h ; DOS: the current drive in ALINT 21hADD AL, "A" ; 0 = A, 1 = B, 2 = C...MOV DL, ALMOV AH, 02h ; DOS: print DLINT 21hMOV DL, ":"MOV AH, 02hINT 21hMOV DX, OFFSET CRLFMOV AH, 09hINT 21hMSG1 DB "the current drive is $"CRLF DB 13, 10, "$"
Programs call it to build full path names (the letter, then ":\" and the directory from INT 21h AH=47h), and to save the drive before switching with INT 21h AH=0Eh, so they can switch back.
Counting from 0, and from 1
DOS numbers drives two ways, and mixing them up gives an off-by-one that points at the wrong drive:
| Service | Drive numbers |
|---|---|
| 0Eh select, 19h get | 0 = A, 1 = B, 2 = C |
| 36h free space, 47h current directory, 1Ch allocation information | 0 = the current drive, 1 = A, 2 = B, 3 = C |
| FCBs, byte 0 | 0 = the current drive, 1 = A |
| BIOS INT 13h | not letters but units: 0 = first floppy, 80h = first hard disk |
So the drive 19h returns has to be incremented before it is passed to 36h or 47h, which is why both of those accept 0 for the current drive: it saves the call.