Int 21H [2.0] Function 47H (71) Get current directory

Obtains an ASCIIZ string that describes the path from the root to the current directory, and the name of that directory.

Call with:

AH = 47H

DL = drive code (0 = default, 1 = A, etc.)

DS:SI = segment:offset of 64-byte buffer

Returns:

If function successful

Carry flag = clear

and buffer is filled in with full pathname from root of current directory.

If function unsuccessful

Carry flag = set

AX = error code

Notes:

The returned path name does not include the drive identifier or a leading backslash (\). It is terminated with a null (00H) byte. Consequently, if the current directory is the root directory, the first byte in the buffer will contain 00H.

The function fails if the drive code is invalid.

The current directory may be set with Int 21H Function 3BH.

Example:

Get the name of the current directory for drive C into the buffer named dbuff.

dbuff db 64 dup (0) ; receives path string

.

.

.

mov ah,47h ; function number

mov dl,03 ; drive C = 3

mov si,seg dbuff ; buffer address

mov ds,si

mov si,offset dbuff

int 21h ; transfer to MS-DOS

jc error ; jump if error

.

.

.