Implement searching directory for exact matches
This commit is contained in:
parent
7754312609
commit
9a1c4139a6
@ -31,24 +31,21 @@ init: cli
|
|||||||
|
|
||||||
call logdrv
|
call logdrv
|
||||||
|
|
||||||
xor ax, ax
|
mov bx, testfcb
|
||||||
xor dx, dx
|
call fndfst
|
||||||
call maprd
|
jc huh
|
||||||
|
call putfn
|
||||||
inc word [dskbuf+0x82]
|
|
||||||
push word [dskbuf+0x82]
|
|
||||||
|
|
||||||
call dirty
|
|
||||||
call flush
|
|
||||||
|
|
||||||
call printf
|
|
||||||
db "Current run: ",2,0x0A,0x0D,0
|
|
||||||
|
|
||||||
hlt: hlt
|
hlt: hlt
|
||||||
jmp hlt
|
jmp hlt
|
||||||
|
|
||||||
|
huh: call printf
|
||||||
|
db "huh", 0
|
||||||
|
jmp hlt
|
||||||
|
|
||||||
%include "kernel/far.asm"
|
%include "kernel/far.asm"
|
||||||
%include "kernel/fcb.asm"
|
%include "kernel/fcb.asm"
|
||||||
|
%include "kernel/find.asm"
|
||||||
%include "kernel/drive.asm"
|
%include "kernel/drive.asm"
|
||||||
%include "kernel/printf.asm"
|
%include "kernel/printf.asm"
|
||||||
|
|
||||||
|
12
inc/fcb.asm
12
inc/fcb.asm
@ -1,10 +1,2 @@
|
|||||||
struc fcb
|
FCBDEN: equ 23 ; directory entry
|
||||||
.drive resb 1
|
FCBSIZ: equ 30
|
||||||
.filename resb 8
|
|
||||||
.type resb 3
|
|
||||||
.fn2 resb 8
|
|
||||||
.tp2 resb 3
|
|
||||||
.dirpos resw 1
|
|
||||||
.cluster resw 1
|
|
||||||
.recordnum resb 1
|
|
||||||
endstruc
|
|
||||||
|
@ -51,21 +51,21 @@ dinit: ; copy previously set DPT to our data area
|
|||||||
; int 13 stub
|
; int 13 stub
|
||||||
; place reserved for stack switches
|
; place reserved for stack switches
|
||||||
int13: ; debug output
|
int13: ; debug output
|
||||||
push bx
|
;push bx
|
||||||
push dx
|
;push dx
|
||||||
push cx
|
;push cx
|
||||||
push ax
|
;push ax
|
||||||
call printf
|
;call printf
|
||||||
db "int13 CALL AX=",2," CX=",2," DX=",2," BX=",2,0x0A,0x0D,0
|
;db "int13 CALL AX=",2," CX=",2," DX=",2," BX=",2,0x0A,0x0D,0
|
||||||
; do the call
|
; do the call
|
||||||
int 0x13
|
int 0x13
|
||||||
jc .err
|
;jc .err
|
||||||
ret
|
|
||||||
.err: push ax
|
|
||||||
call printf
|
|
||||||
db "int13 ERR AX=",2,0x0A,0x0D,0
|
|
||||||
stc
|
|
||||||
ret
|
ret
|
||||||
|
.err: ;push ax
|
||||||
|
;call printf
|
||||||
|
;db "DISK ERR AX=",2,0x0A,0x0D,0
|
||||||
|
;stc
|
||||||
|
;ret
|
||||||
|
|
||||||
; get drive parameters
|
; get drive parameters
|
||||||
; read BIOS int13h/AH=8 values
|
; read BIOS int13h/AH=8 values
|
||||||
|
@ -9,61 +9,12 @@ section .text
|
|||||||
; Helper function: read the drive number from FCB,
|
; Helper function: read the drive number from FCB,
|
||||||
; apply default if necessary,
|
; apply default if necessary,
|
||||||
; and make it current I/O drive
|
; and make it current I/O drive
|
||||||
setdrv: mov dl, [es:bx+fcb.drive] ; A=1
|
setdrv: mov dl, [es:bx] ; A=1
|
||||||
test dl, dl
|
test dl, dl
|
||||||
jnz .nofix
|
jnz .nofix
|
||||||
mov dl, [defdrv] ; A=0
|
mov dl, [defdrv] ; A=0
|
||||||
inc dl
|
inc dl
|
||||||
mov [es:bx+fcb.drive], dl ; A=1
|
mov [es:bx], dl ; A=1
|
||||||
; now set as current i/o drive
|
; now set as current i/o drive
|
||||||
.nofix: dec dl ; A=0 for dsksel
|
.nofix: dec dl ; A=0 for dsksel
|
||||||
jmp logdrv
|
jmp logdrv
|
||||||
|
|
||||||
; FCB open
|
|
||||||
fcbopn: ; call fcbfst
|
|
||||||
; copy match
|
|
||||||
; store cluster number in fcb
|
|
||||||
; record = 0
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB close
|
|
||||||
fcbcls: ; flush disk buffer
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB find first
|
|
||||||
fcbfst: mov word [es:bx+fcb.dirpos], 0
|
|
||||||
; FCB find next
|
|
||||||
fcbnxt: call setdrv
|
|
||||||
; load rootdir sector from state
|
|
||||||
; search until next match
|
|
||||||
; next sec & loop if mismatch
|
|
||||||
; err exit if no further matches
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB delete file
|
|
||||||
fcbdel: ; call fcbfst
|
|
||||||
; get search state, load root dir from there
|
|
||||||
; mark file as deleted
|
|
||||||
; mark buffer dirty
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB read
|
|
||||||
; read sector from cluster into diskbuf
|
|
||||||
fcbrd: ; read record from sector
|
|
||||||
; advance record num, carry over to cluster
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB write
|
|
||||||
fcbwr: ; read sector from cluster into diskbuf
|
|
||||||
; write record into sector
|
|
||||||
; mark buffer dirty
|
|
||||||
; advance record num, carry over to cluster
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB create
|
|
||||||
fcbcre:
|
|
||||||
ret
|
|
||||||
|
|
||||||
; FCB rename
|
|
||||||
fcbren:
|
|
||||||
ret
|
|
||||||
|
57
kernel/find.asm
Normal file
57
kernel/find.asm
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
; Load root directory entry
|
||||||
|
; IN ax number of directory entry
|
||||||
|
lddir: push ax
|
||||||
|
mov cl, 4
|
||||||
|
shr ax, cl
|
||||||
|
xor dx, dx
|
||||||
|
call maprd
|
||||||
|
; get si to point to entry
|
||||||
|
pop si
|
||||||
|
mov cl, 5
|
||||||
|
shl si, cl
|
||||||
|
and si, 0x1FF
|
||||||
|
add si, dskbuf
|
||||||
|
ret
|
||||||
|
|
||||||
|
; find next file
|
||||||
|
fnfile: mov ax, [es:bx+FCBDEN]
|
||||||
|
inc word [es:bx+FCBDEN]
|
||||||
|
; 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 fnfile
|
||||||
|
; bail out if end of dir
|
||||||
|
mov al, [si]
|
||||||
|
cmp al, 0
|
||||||
|
je .err
|
||||||
|
; next if deleted entry
|
||||||
|
cmp al, 0xE5
|
||||||
|
je fnfile
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
.err: stc
|
||||||
|
ret
|
||||||
|
|
||||||
|
; initialize a FCB for directory scanning
|
||||||
|
fndfst: mov word [es:bx+FCBDEN], 0
|
||||||
|
fndnxt: call fnfile
|
||||||
|
jc .ret
|
||||||
|
push si
|
||||||
|
lea di, [bx+1]
|
||||||
|
mov cx, 11
|
||||||
|
rep cmpsb
|
||||||
|
pop si
|
||||||
|
jne fndnxt
|
||||||
|
.ret: ret
|
||||||
|
|
||||||
|
putfn: mov cx, 11
|
||||||
|
.loop: lodsb
|
||||||
|
call pputc
|
||||||
|
loop .loop
|
||||||
|
ret
|
Loading…
Reference in New Issue
Block a user