-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindfile.asm
78 lines (74 loc) · 1.78 KB
/
findfile.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;---------------------------------------------------------------------------;
; /* FindFirst; searches for first matching file in directory ;
; ;
; Input: ;
; DGROUP:DX wildcard ;
; ;
; Output: ;
; C=0 ; successfull ;
; [DTA] file data block ;
; C=1 ; unsuccessfull ;
; AX error code */ ;
;---------------------------------------------------------------------------;
.code
FindFirst: ASSUME ds:NOTHING, es:NOTHING
push ds ; save DS
push cx ; save CX
mov ds,SegData
ASSUME ds:DGROUP
mov cx,_SearchAttrib
mov ah,4Eh
int 21h
pop cx ; restore CX
push di
jmp _CheckIfExec
.data
_SearchAttrib dw 0
;---------------------------------------------------------------------------;
; /* FindNext; searches for next matching file in directory ;
; ;
; Input: ;
; nothing ;
; ;
; Output: ;
; C=0 ; successfull ;
; [DTA] file data block ;
; C=1 ; unsuccessfull ;
; AX error code */ ;
;---------------------------------------------------------------------------;
.code
FindNext: ASSUME ds:NOTHING, es:NOTHING
push ds ; save DS
mov ds,SegData
push di
ASSUME ds:DGROUP
_SearchNext:
mov ah,4Fh
int 21h
_CheckIfExec:
jc _NoMore
cmp _ExecOnly,FALSE
je _FoundOne
push si
mov si,offset DTA_Filename
call FindExtention
pop si
cmp [di],'C.'
je _CheckCOM
cmp [di],'E.'
jne _SearchNext
cmp [di+2],'EX'
jne _SearchNext
_FoundOne:
clc
_NoMore:
pop di
pop ds ; restore DS
ASSUME ds:NOTHING
ret
_CheckCOM:
cmp [di+2],'MO'
jne _SearchNext
jmp _FoundOne
.data
_ExecOnly db FALSE