BIOS和DOS中断大全_DOS中断_02目录控制功能
2、目录控制功能(Directory-Control Function)
接上文: BIOS和DOS中断大全列程_DOS中断_01字符调用类
INT 21h 中断
(1)、功能39H
功能描述:用指定的驱动器和路径创建一个新目录
入口参数:
AH=39H
DS:DX=指定路径的字符串地址(以0为字符串的结束标志)
出口参数:CF=0——创建成功,否则,AX=错误号(03H或05H),其含义见错误代码表
例程:
1: assume cs:code
2:
3: data segment
4: path db 'c:/123', 0
5: successstr db 'create path success!$', 0
6: failstr db 'create path fail!$', 0
7: data ends
8:
9: code segment
10: start:
11: mov ax, data
12: mov ds, ax
13:
14: lea dx, path
15: xor ax, ax
16: mov ah, 39h
17: int 21h
18: jc fail
19: success:
20: lea dx, successstr
21: mov ah, 09h
22: int 21h
23: jmp codeEnd
24: fail:
25: lea dx, failstr
26: mov ah, 09h
27: int 21h
28: codeEnd:
29: mov ax, 4c00h
30: int 21h
31: code ends
32: end start
(2)、功能3AH
功能描述:删除指定的驱动器和路径的目录
入口参数:
AH=3AH
DS:DX=指定路径的字符串地址(以0为字符串的结束标志)
出口参数:CF=0——删除成功,否则,AX=错误号(03H或05H),其含义见错误代码表
例程:
1: assume cs:code
2:
3: data segment
4: path db 'c:/123', 0
5: successstr db 'delete path success!$', 0
6: failstr db 'delete path fail!$', 0
7: data ends
8:
9: code segment
10: start:
11: mov ax, data
12: mov ds, ax
13:
14: lea dx, path
15: xor ax, ax
16: mov ah, 3Ah
17: int 21h
18: jc fail
19: success:
20: lea dx, successstr
21: mov ah, 09h
22: int 21h
23: jmp codeEnd
24: fail:
25: lea dx, failstr
26: mov ah, 09h
27: int 21h
28: codeEnd:
29: mov ax, 4c00h
30: int 21h
31: code ends
32: end start
(3)、功能3BH
功能描述:用指定的驱动器和路径设置为当前目录
入口参数:
AH=3BH
DS:DX=指定路径的字符串地址(以0为字符串的结束标志)
出口参数:CF=0——设置成功,否则,AX=错误号(03H),其含义见错误代码表
例程:
1: assume cs:code
2:
3: data segment
4: path db 'c:/123', 0
5: failstr db 'fetch current path fail!$', 0
6: result db 255 dup(0)
7: data ends
8:
9: code segment
10: print:
11: push bx
12: push ax
13: push dx
14: printStart:
15: cmp byte ptr ds:[bx], 0
16: jz printEnd
17: mov dl, ds:[bx]
18: call printChar
19: inc bx
20: jmp printStart
21: printEnd:
22: pop dx
23: pop ax
24: pop bx
25: ret
26:
27: ; input - dl
28: printChar:
29: mov ah, 02h
30: int 21h
31: ret
32:
33: start:
34: mov ax, data
35: mov ds, ax
36:
37: mov ah, 3bh
38: lea dx, path
39:
40: int 21h
41:
42: jc fail
43:
44: xor ax, ax
45: xor dx, dx
46: mov ah, 47h
47: lea si, result
48:
49: int 21h
50: jc fail
51: success:
52: mov bx, si
53: call print
54: jmp codeEnd
55: fail:
56: lea dx, failstr
57: mov ah, 09h
58: int 21h
59: codeEnd:
60: mov ax, 4c00h
61: int 21h
62: code ends
63: end start
(4)、功能47H
功能描述:取当前目录的完全路径字符串
入口参数:
AH=47H
DL=驱动器号(0=缺省,1=A,…)
DS:SI=存放当前目录字符串的地址
出口参数:CF=0——读取成功,否则,AX=错误号(0FH),其含义见错误代码表
例程: 请参看 (3)、功能3BH