source: xtideuniversalbios/trunk/Assembly_Library/Src/File/Directory.asm@ 96

Last change on this file since 96 was 41, checked in by Tomi Tilli, 14 years ago

Initial commit for Assembly Library.

File size: 4.0 KB
RevLine 
[41]1; File name : Directory.asm
2; Project name : Assembly Library
3; Created date : 3.9.2010
4; Last update : 6.9.2010
5; Author : Tomi Tilli
6; Description : Functions for accessing directories.
7
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Directory_GetDiskTransferAreaAddressToDSSI
14; Parameters:
15; Nothing
16; Returns:
17; DS:SI: Ptr to DTA
18; Corrupts registers:
19; AX
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22Directory_GetDiskTransferAreaAddressToDSSI:
23 push es
24 push bx
25
26 mov ah, GET_DISK_TRANSFER_AREA_ADDRESS
27 int DOS_INTERRUPT_21h
28 push es
29 pop ds
30 mov si, bx
31
32 pop bx
33 pop es
34 ret
35
36
37;--------------------------------------------------------------------
38; Directory_ChangeToPathFromDSSI
39; Parameters:
40; DS:SI: Ptr to NULL terminated path (max 64 bytes)
41; Returns:
42; AX: Error code
43; CF: Cleared if success
44; Set if error
45; Corrupts registers:
46; Nothing
47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49Directory_ChangeToPathFromDSSI:
50 xchg dx, si ; Path now in DS:DX
51 mov ah, SET_CURRENT_DIRECTORY
52 int DOS_INTERRUPT_21h
53 xchg si, dx
54 ret
55
56
57;--------------------------------------------------------------------
58; Directory_WriteCurrentPathToDSSI
59; Parameters:
60; DS:SI: Ptr to destination buffer (64 bytes)
61; Returns:
62; AX: Error code
63; CF: Cleared if success
64; Set if error
65; Corrupts registers:
66; Nothing
67;--------------------------------------------------------------------
68ALIGN JUMP_ALIGN
69Directory_WriteCurrentPathToDSSI:
70 push dx
71
72 xor dx, dx ; Default drive (00h)
73 mov ah, GET_CURRENT_DIRECTORY
74 int DOS_INTERRUPT_21h
75
76 pop dx
77 ret
78
79
80;--------------------------------------------------------------------
81; Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX
82; Parameters:
83; CX: File attributes
84; DS:SI: NULL terminated search string (may include path and wildcards)
85; Returns:
86; AX: Number of matching files found
87; Corrupts registers:
88; Nothing
89;--------------------------------------------------------------------
90ALIGN JUMP_ALIGN
91Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX:
92 push dx
93 xor dx, dx ; Zero counter
94 call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
95 jc SHORT .NoMoreFilesFound
96ALIGN JUMP_ALIGN
97.FindNextFile:
98 inc dx ; Increment match count
99 call Directory_UpdateDTAForNextMatchUsingPreviousParameters
100 jnc SHORT .FindNextFile
101ALIGN JUMP_ALIGN
102.NoMoreFilesFound:
103 xchg ax, dx ; Match count to AX
104 pop dx
105 ret
106
107
108;--------------------------------------------------------------------
109; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
110; Parameters:
111; CX: File attributes
112; DS:SI: NULL terminated search string (may include path and wildcards)
113; Returns:
114; AX: Error code
115; CF: Cleared if success
116; Set if error
117; Disk Transfer Area (DTA) will be updated
118; Corrupts registers:
119; Nothing
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX:
123 xchg dx, si ; Search string now in DS:DX
124 mov ax, FIND_FIRST_MATCHING_FILE<<8 ; Zero AL (special flag for APPEND)
125 int DOS_INTERRUPT_21h
126 xchg si, dx
127 ret
128
129
130;--------------------------------------------------------------------
131; Directory_UpdateDTAForNextMatchUsingPreviousParameters
132; Parameters:
133; Nothing (Parameters from previous call to
134; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX are used)
135; Returns:
136; AX: Error code
137; CF: Cleared if success
138; Set if error
139; Disk Transfer Area (DTA) will be updated
140; Corrupts registers:
141; Nothing
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144Directory_UpdateDTAForNextMatchUsingPreviousParameters:
145 mov ah, FIND_NEXT_MATCHING_FILE
146 int DOS_INTERRUPT_21h
147 ret
Note: See TracBrowser for help on using the repository browser.