Subversion Repositories SvarDOS

Rev

Rev 1155 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1155 Rev 1203
1
;
1
;
2
; lists files using first or second FCB provided by COMMAND.COM in PSP
2
; lists files using first or second FCB provided by COMMAND.COM in PSP
3
; Copyright (C) 2022 Mateusz Viste
3
; Copyright (C) 2022 Mateusz Viste
4
;
4
;
5
; to be assembled with NASM.
5
; to be assembled with NASM.
6
;
6
;
7
; lists file entries matching first argument of the program using the default
7
; lists file entries matching first argument of the program using the default
8
; unopened FCB entry in PSP as preset by COMMAND.COM.
8
; unopened FCB entry in PSP as preset by COMMAND.COM.
9
;
9
;
10
; usage: fcbdir file-pattern
10
; usage: fcbdir file-pattern
11
;
11
;
12
; example: fcbdir c:*.txt
12
; example: fcbdir c:*.txt
13
;
13
;
14
 
14
 
15
CPU 8086
15
CPU 8086
16
org 0x100
16
org 0x100
17
 
17
 
18
; print whatever drive/filename is set at 0x5C (1st unopened FCB in the PSP)
18
; print whatever drive/filename is set at 0x5C (1st unopened FCB in the PSP)
19
mov dx, PARAM
19
mov dx, PARAM
20
mov ah, 0x09
20
mov ah, 0x09
21
int 0x21
21
int 0x21
22
 
22
 
23
mov bx, 0x5C
23
mov bx, 0x5C
24
call PRINTDTA
24
call PRINTDTA
25
 
25
 
26
; FindFirst_FCB applied to PSP:5C (1st unopened FCB)
26
; FindFirst_FCB applied to PSP:5C (1st unopened FCB)
27
mov dx, 0x5C
27
mov dx, 0x5C
28
mov ah, 0x11
28
mov ah, 0x11
29
int 0x21
29
int 0x21
30
 
30
 
31
cmp al, 0
31
cmp al, 0
32
jne GAMEOVER
32
jne GAMEOVER
33
 
33
 
34
NEXT:
34
NEXT:
35
 
35
 
36
; print filename in DTA
36
; print filename in DTA
37
mov bx, 0x80
37
mov bx, 0x80
38
call PRINTDTA
38
call PRINTDTA
39
 
39
 
40
; FindNext_FCB on PSP until nothing left
40
; FindNext_FCB on PSP until nothing left
41
mov ah, 0x12
41
mov ah, 0x12
42
mov dx, 0x5C
42
mov dx, 0x5C
43
int 0x21
43
int 0x21
44
cmp al, 0
44
cmp al, 0
45
je NEXT
45
je NEXT
46
 
46
 
47
GAMEOVER:
47
GAMEOVER:
48
 
48
 
49
int 0x20
49
int 0x20
50
 
50
 
51
PARAM:
51
PARAM:
52
db "PARAMETER = $";
52
db "PARAMETER = $";
53
 
53
 
54
 
54
 
55
; ****** print the filename present in the DTA (DTA is at [BX]) ******
55
; ****** print the filename present in the DTA (DTA is at [BX]) ******
56
PRINTDTA:
56
PRINTDTA:
57
; print drive in the DTA
57
; print drive in the DTA
58
mov ah, 0x02
58
mov ah, 0x02
59
mov dl, [bx]
59
mov dl, [bx]
60
add dl, '@'
60
add dl, '@'
61
int 0x21
61
int 0x21
62
mov dl, ':'
62
mov dl, ':'
63
int 0x21
63
int 0x21
64
; print filename/extension (in FCB format)
64
; print filename/extension (in FCB format)
65
mov ah, 0x40    ; write to file
65
mov ah, 0x40    ; write to file
66
mov cx, 11      ; 11 bytes (8+3)
66
mov cx, 11      ; 11 bytes (8+3)
67
mov dx, bx      ; filename field at the default DTA location
67
mov dx, bx      ; filename field at the default DTA location
68
inc dx
68
inc dx
69
mov bx, 1       ; output to stdout
69
mov bx, 1       ; output to stdout
70
int 0x21
70
int 0x21
71
; print a trailing CR/LF
71
; print a trailing CR/LF
72
mov ah, 0x02    ; display character in DL
72
mov ah, 0x02    ; display character in DL
73
mov dl, 0x0D    ; CR
73
mov dl, 0x0D    ; CR
74
int 0x21
74
int 0x21
75
mov dl, 0x0A    ; LF
75
mov dl, 0x0A    ; LF
76
int 0x21
76
int 0x21
77
ret
77
ret
78
 
78