Implement file search in directory
This commit is contained in:
parent
4530866130
commit
ebd356ed8e
@ -35,13 +35,9 @@ relinit: ; print banner
|
|||||||
push word [version+2]
|
push word [version+2]
|
||||||
call printf
|
call printf
|
||||||
db "RDOS ",2,2, 0x0A, 0x0D, 0
|
db "RDOS ",2,2, 0x0A, 0x0D, 0
|
||||||
|
; initialize the disk i/o
|
||||||
push dx
|
|
||||||
push ds
|
|
||||||
call dinit
|
call dinit
|
||||||
pop ds
|
; init 21h vector
|
||||||
pop dx
|
|
||||||
|
|
||||||
mov word [0x21*4], int21
|
mov word [0x21*4], int21
|
||||||
mov word [0x21*4+2], cs
|
mov word [0x21*4+2], cs
|
||||||
; set current PSP, directly after us
|
; set current PSP, directly after us
|
||||||
@ -49,15 +45,19 @@ relinit: ; print banner
|
|||||||
mov cl, 4
|
mov cl, 4
|
||||||
shr ax, cl
|
shr ax, cl
|
||||||
mov word [curpsp], ax
|
mov word [curpsp], ax
|
||||||
|
; also the DTA
|
||||||
|
mov bx, dta
|
||||||
|
call setdta
|
||||||
|
; set current drive to boot drive
|
||||||
|
mov al, dl
|
||||||
|
rol al, 1
|
||||||
|
rol al, 1
|
||||||
|
or dl, al
|
||||||
|
and dl, 3
|
||||||
|
call setdd
|
||||||
|
|
||||||
cmp dl, 0x80
|
mov bx, testfcb
|
||||||
jc .k
|
call fndfst
|
||||||
sub dl, (0x80-2)
|
|
||||||
.k: call setdd
|
|
||||||
|
|
||||||
mov dx, testfcb
|
|
||||||
mov ah, 0xF
|
|
||||||
int 0x21
|
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
hlt: hlt
|
hlt: hlt
|
||||||
@ -70,6 +70,10 @@ hlt: hlt
|
|||||||
%include "kernel/drive.asm"
|
%include "kernel/drive.asm"
|
||||||
%include "kernel/printf.asm"
|
%include "kernel/printf.asm"
|
||||||
|
|
||||||
|
section .bss
|
||||||
|
|
||||||
|
dta: resb 128
|
||||||
|
|
||||||
section .data
|
section .data
|
||||||
|
|
||||||
testfcb: db 0
|
testfcb: db 0
|
||||||
|
@ -34,6 +34,7 @@ section .text
|
|||||||
|
|
||||||
; initial setup for disk i/o
|
; initial setup for disk i/o
|
||||||
dinit: ; copy previously set DPT to our data area
|
dinit: ; copy previously set DPT to our data area
|
||||||
|
push ds
|
||||||
push cs
|
push cs
|
||||||
pop es
|
pop es
|
||||||
lds si, [es:4*0x1E]
|
lds si, [es:4*0x1E]
|
||||||
@ -45,6 +46,7 @@ dinit: ; copy previously set DPT to our data area
|
|||||||
mov word [cs:4*0x1E+2], ds
|
mov word [cs:4*0x1E+2], ds
|
||||||
; set to invalid drive
|
; set to invalid drive
|
||||||
mov byte [cs:dsknum], 0xFF
|
mov byte [cs:dsknum], 0xFF
|
||||||
|
pop ds
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; int 13 stub
|
; int 13 stub
|
||||||
|
@ -10,14 +10,18 @@ FCBSIZ: equ 30
|
|||||||
section .text
|
section .text
|
||||||
|
|
||||||
; auto-complete drive field in fcb
|
; auto-complete drive field in fcb
|
||||||
|
; also returns the drive number
|
||||||
; IN es:bx far ptr FCB
|
; IN es:bx far ptr FCB
|
||||||
; OUT si copy of bx
|
; OUT dl dl (0=A:, 1=B:, 2=C:, ...)
|
||||||
fixfcb: cmp byte [es:bx], 0
|
fcbdrv: mov dl, [es:bx]
|
||||||
jne .ret
|
test dl, dl
|
||||||
|
jnz .ret
|
||||||
call getdd
|
call getdd
|
||||||
|
mov dl, al
|
||||||
inc dl
|
inc dl
|
||||||
mov byte [es:bx], dl
|
mov [es:bx], dl
|
||||||
.ret: ret
|
.ret: dec dl
|
||||||
|
ret
|
||||||
|
|
||||||
; Load root directory entry
|
; Load root directory entry
|
||||||
; IN ax number of directory entry
|
; IN ax number of directory entry
|
||||||
@ -37,8 +41,55 @@ lddir: push ax
|
|||||||
|
|
||||||
; find first matching file
|
; find first matching file
|
||||||
; IN ES:BX input fcb
|
; IN ES:BX input fcb
|
||||||
fndfst:
|
fndfst: ; get and log in drive
|
||||||
|
call fcbdrv
|
||||||
|
call logdrv
|
||||||
|
; set search state to zero
|
||||||
|
push es
|
||||||
|
push bx
|
||||||
|
call getdta
|
||||||
|
xor ax, ax
|
||||||
|
mov [es:bx+0x20+1], ax
|
||||||
|
pop bx
|
||||||
|
pop es
|
||||||
|
; find next matching file
|
||||||
|
; state is kept in DTA
|
||||||
|
fndnxt: ; get net direntry to fetch
|
||||||
|
; get number of current entry from DTA
|
||||||
|
push es
|
||||||
|
push bx
|
||||||
|
call getdta
|
||||||
|
mov ax, [es:bx+0x20+1]
|
||||||
|
inc word [es:bx+0x20+1]
|
||||||
|
pop bx
|
||||||
|
pop es
|
||||||
|
; bail out if we are at end of dir
|
||||||
|
cmp ax, [bpb+BPBRDE]
|
||||||
|
jnc .err
|
||||||
|
; load entry and first byte
|
||||||
|
push bx
|
||||||
|
call lddir
|
||||||
|
pop bx
|
||||||
|
; next if hidden, dir or vol label
|
||||||
|
test byte [si+0x0B], 0xDA
|
||||||
|
jnz fndnxt
|
||||||
|
; bail out if end of dir
|
||||||
|
mov al, [si]
|
||||||
|
cmp al, 0
|
||||||
|
je .err
|
||||||
|
; next if deleted entry
|
||||||
|
cmp al, 0xE5
|
||||||
|
je fndnxt
|
||||||
|
; compate DS:SI with ES:BX+1
|
||||||
|
lea di, [bx+1]
|
||||||
|
mov cx, 11
|
||||||
|
rep cmpsb
|
||||||
|
; try next if mismatch
|
||||||
|
jne fndnxt
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
.err: stc
|
||||||
|
ret
|
||||||
|
|
||||||
open:
|
open:
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user