Int 21H [2.0] Function 3BH (59) Set current directory

Sets the current, or default, directory using the specified drive and path.

Call with:

AH = 3BH

DS:DX = segment:offset of ASCIIZ pathname

Returns:

If function successful

Carry flag = clear

If function unsuccessful

Carry flag = set

AX = error code

Notes:

The function fails if any element of the pathname does not exist.

Int 21H Function 47H can be used to obtain the name of the current directory before using Int 21H Function 3BH to select another, so that the original directory can be restored later.

Example:

Change the current directory for drive C to the directory \MYSUB.

dname db 'C:\MYSUB',0

.

.

.

mov ah,3bh ; function number

mov dx,seg dname ; address of pathname

mov ds,dx

mov dx,offset dname

int 21h ; transfer to MS-DOS

jc error ; jump if bad path

.

.

.