1 | ; Project name : Assembly Library |
---|
2 | ; Description : Functions for accessing directories. |
---|
3 | |
---|
4 | ; |
---|
5 | ; XTIDE Universal BIOS and Associated Tools |
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
7 | ; |
---|
8 | ; This program is free software; you can redistribute it and/or modify |
---|
9 | ; it under the terms of the GNU General Public License as published by |
---|
10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
11 | ; (at your option) any later version. |
---|
12 | ; |
---|
13 | ; This program is distributed in the hope that it will be useful, |
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | ; GNU General Public License for more details. |
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
18 | ; |
---|
19 | |
---|
20 | ; Section containing code |
---|
21 | SECTION .text |
---|
22 | |
---|
23 | ;-------------------------------------------------------------------- |
---|
24 | ; Directory_GetDiskTransferAreaAddressToDSSI |
---|
25 | ; Parameters: |
---|
26 | ; Nothing |
---|
27 | ; Returns: |
---|
28 | ; DS:SI: Ptr to DTA |
---|
29 | ; Corrupts registers: |
---|
30 | ; AX |
---|
31 | ;-------------------------------------------------------------------- |
---|
32 | ALIGN JUMP_ALIGN |
---|
33 | Directory_GetDiskTransferAreaAddressToDSSI: |
---|
34 | push es |
---|
35 | push bx |
---|
36 | |
---|
37 | mov ah, GET_DISK_TRANSFER_AREA_ADDRESS |
---|
38 | int DOS_INTERRUPT_21h |
---|
39 | push es |
---|
40 | pop ds |
---|
41 | mov si, bx |
---|
42 | |
---|
43 | pop bx |
---|
44 | pop es |
---|
45 | ret |
---|
46 | |
---|
47 | |
---|
48 | ;-------------------------------------------------------------------- |
---|
49 | ; Directory_ChangeToPathFromDSSI |
---|
50 | ; Parameters: |
---|
51 | ; DS:SI: Ptr to NULL terminated path (max 64 bytes) |
---|
52 | ; Returns: |
---|
53 | ; AX: Error code |
---|
54 | ; CF: Cleared if success |
---|
55 | ; Set if error |
---|
56 | ; Corrupts registers: |
---|
57 | ; Nothing |
---|
58 | ;-------------------------------------------------------------------- |
---|
59 | ALIGN JUMP_ALIGN |
---|
60 | Directory_ChangeToPathFromDSSI: |
---|
61 | xchg dx, si ; Path now in DS:DX |
---|
62 | mov ah, SET_CURRENT_DIRECTORY |
---|
63 | int DOS_INTERRUPT_21h |
---|
64 | xchg si, dx |
---|
65 | ret |
---|
66 | |
---|
67 | |
---|
68 | ;-------------------------------------------------------------------- |
---|
69 | ; Directory_WriteCurrentPathToDSSI |
---|
70 | ; Parameters: |
---|
71 | ; DS:SI: Ptr to destination buffer (64 bytes) |
---|
72 | ; Returns: |
---|
73 | ; AX: Error code |
---|
74 | ; CF: Cleared if success |
---|
75 | ; Set if error |
---|
76 | ; Corrupts registers: |
---|
77 | ; Nothing |
---|
78 | ;-------------------------------------------------------------------- |
---|
79 | ALIGN JUMP_ALIGN |
---|
80 | Directory_WriteCurrentPathToDSSI: |
---|
81 | push dx |
---|
82 | |
---|
83 | mov ah, GET_CURRENT_DIRECTORY ; GET_CURRENT_DIRECTORY = 47h |
---|
84 | cwd ; Default drive (00h) |
---|
85 | int DOS_INTERRUPT_21h |
---|
86 | |
---|
87 | pop dx |
---|
88 | ret |
---|
89 | |
---|
90 | |
---|
91 | ;-------------------------------------------------------------------- |
---|
92 | ; Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX |
---|
93 | ; Parameters: |
---|
94 | ; CX: File attributes |
---|
95 | ; DS:SI: NULL terminated search string (may include path and wildcards) |
---|
96 | ; Returns: |
---|
97 | ; AX: Number of matching files found |
---|
98 | ; Corrupts registers: |
---|
99 | ; Nothing |
---|
100 | ;-------------------------------------------------------------------- |
---|
101 | ALIGN JUMP_ALIGN |
---|
102 | Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX: |
---|
103 | push dx |
---|
104 | xor dx, dx ; Zero counter |
---|
105 | call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX |
---|
106 | jc SHORT .NoMoreFilesFound |
---|
107 | ALIGN JUMP_ALIGN |
---|
108 | .FindNextFile: |
---|
109 | inc dx ; Increment match count |
---|
110 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters |
---|
111 | jnc SHORT .FindNextFile |
---|
112 | ALIGN JUMP_ALIGN |
---|
113 | .NoMoreFilesFound: |
---|
114 | xchg ax, dx ; Match count to AX |
---|
115 | pop dx |
---|
116 | ret |
---|
117 | |
---|
118 | |
---|
119 | ;-------------------------------------------------------------------- |
---|
120 | ; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX |
---|
121 | ; Parameters: |
---|
122 | ; CX: File attributes |
---|
123 | ; DS:SI: NULL terminated search string (may include path and wildcards) |
---|
124 | ; Returns: |
---|
125 | ; AX: Error code |
---|
126 | ; CF: Cleared if success |
---|
127 | ; Set if error |
---|
128 | ; Disk Transfer Area (DTA) will be updated |
---|
129 | ; Corrupts registers: |
---|
130 | ; Nothing |
---|
131 | ;-------------------------------------------------------------------- |
---|
132 | ALIGN JUMP_ALIGN |
---|
133 | Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX: |
---|
134 | xchg dx, si ; Search string now in DS:DX |
---|
135 | mov ax, FIND_FIRST_MATCHING_FILE<<8 ; Zero AL (special flag for APPEND) |
---|
136 | int DOS_INTERRUPT_21h |
---|
137 | xchg si, dx |
---|
138 | ret |
---|
139 | |
---|
140 | |
---|
141 | ;-------------------------------------------------------------------- |
---|
142 | ; Directory_UpdateDTAForNextMatchUsingPreviousParameters |
---|
143 | ; Parameters: |
---|
144 | ; Nothing (Parameters from previous call to |
---|
145 | ; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX are used) |
---|
146 | ; Returns: |
---|
147 | ; AX: Error code |
---|
148 | ; CF: Cleared if success |
---|
149 | ; Set if error |
---|
150 | ; Disk Transfer Area (DTA) will be updated |
---|
151 | ; Corrupts registers: |
---|
152 | ; Nothing |
---|
153 | ;-------------------------------------------------------------------- |
---|
154 | ALIGN JUMP_ALIGN |
---|
155 | Directory_UpdateDTAForNextMatchUsingPreviousParameters: |
---|
156 | mov ah, FIND_NEXT_MATCHING_FILE |
---|
157 | int DOS_INTERRUPT_21h |
---|
158 | ret |
---|