[41] | 1 | ; Project name : Assembly Library |
---|
| 2 | ; Description : Functions for accessing directories. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 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. |
---|
[526] | 12 | ; |
---|
[376] | 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 |
---|
[526] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
[526] | 19 | |
---|
[41] | 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 | |
---|
[116] | 83 | mov ah, GET_CURRENT_DIRECTORY ; GET_CURRENT_DIRECTORY = 47h |
---|
| 84 | cwd ; Default drive (00h) |
---|
[41] | 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 | ;-------------------------------------------------------------------- |
---|
[592] | 101 | %ifndef EXCLUDE_FROM_XTIDECFG |
---|
[41] | 102 | ALIGN JUMP_ALIGN |
---|
| 103 | Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX: |
---|
| 104 | push dx |
---|
| 105 | xor dx, dx ; Zero counter |
---|
| 106 | call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX |
---|
| 107 | jc SHORT .NoMoreFilesFound |
---|
| 108 | ALIGN JUMP_ALIGN |
---|
| 109 | .FindNextFile: |
---|
| 110 | inc dx ; Increment match count |
---|
| 111 | call Directory_UpdateDTAForNextMatchUsingPreviousParameters |
---|
| 112 | jnc SHORT .FindNextFile |
---|
| 113 | ALIGN JUMP_ALIGN |
---|
| 114 | .NoMoreFilesFound: |
---|
| 115 | xchg ax, dx ; Match count to AX |
---|
| 116 | pop dx |
---|
| 117 | ret |
---|
[592] | 118 | %endif |
---|
[41] | 119 | |
---|
| 120 | |
---|
| 121 | ;-------------------------------------------------------------------- |
---|
| 122 | ; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX |
---|
| 123 | ; Parameters: |
---|
| 124 | ; CX: File attributes |
---|
| 125 | ; DS:SI: NULL terminated search string (may include path and wildcards) |
---|
| 126 | ; Returns: |
---|
| 127 | ; AX: Error code |
---|
| 128 | ; CF: Cleared if success |
---|
| 129 | ; Set if error |
---|
| 130 | ; Disk Transfer Area (DTA) will be updated |
---|
| 131 | ; Corrupts registers: |
---|
| 132 | ; Nothing |
---|
| 133 | ;-------------------------------------------------------------------- |
---|
| 134 | ALIGN JUMP_ALIGN |
---|
| 135 | Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX: |
---|
| 136 | xchg dx, si ; Search string now in DS:DX |
---|
| 137 | mov ax, FIND_FIRST_MATCHING_FILE<<8 ; Zero AL (special flag for APPEND) |
---|
| 138 | int DOS_INTERRUPT_21h |
---|
| 139 | xchg si, dx |
---|
| 140 | ret |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | ;-------------------------------------------------------------------- |
---|
| 144 | ; Directory_UpdateDTAForNextMatchUsingPreviousParameters |
---|
| 145 | ; Parameters: |
---|
[116] | 146 | ; Nothing (Parameters from previous call to |
---|
[41] | 147 | ; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX are used) |
---|
| 148 | ; Returns: |
---|
| 149 | ; AX: Error code |
---|
| 150 | ; CF: Cleared if success |
---|
| 151 | ; Set if error |
---|
| 152 | ; Disk Transfer Area (DTA) will be updated |
---|
| 153 | ; Corrupts registers: |
---|
| 154 | ; Nothing |
---|
| 155 | ;-------------------------------------------------------------------- |
---|
| 156 | ALIGN JUMP_ALIGN |
---|
| 157 | Directory_UpdateDTAForNextMatchUsingPreviousParameters: |
---|
| 158 | mov ah, FIND_NEXT_MATCHING_FILE |
---|
| 159 | int DOS_INTERRUPT_21h |
---|
| 160 | ret |
---|