rdos/kernel/fcb.asm

71 lines
849 B
NASM

; Parse ASCIIZ string into FCB
; IN SI ptr to filename
; BX ptr to FCB
fcb_parse:
push di
push ax
mov di, bx
xor ax, ax
stosb
.cleanout:
push di
mov cx, 0x0A
mov al, 0x20
rep stosb
pop di
.base_loop:
call .read
cmp al, 0x2E
je .ext_start
cmp al, 0x20
je .ret
stosb
jmp .base_loop
.ext_start:
mov di, bx
add di, 9
.ext_loop:
call .read
cmp al, 0x20
je .ret
stosb
jmp .ext_loop
.read:
lodsb
test al, al
jz .eret
cmp al, 0x0D
je .eret
ret
.eret:
dec si
pop ax
.ret:
pop ax
pop di
ret
fcb_open:
cmp byte [bx], 0
jne .drivedone
mov al, default_drive
inc al
mov [bx], al
.drivedone:
push bp
sub sp, bpb_size
mov bp, sp
mov dl, [bx]
dec dl
call bpb_load
mov ax, [bp]
mov cx, [bp+2]
mov dx, [bp+4]
mov bx, [bp+6]
add sp, bpb_size
pop bp
ret