69 lines
797 B
NASM
69 lines
797 B
NASM
|
; Parse ASCIIZ string into FCB
|
||
|
; IN SI ptr to filename
|
||
|
; BX ptr to FCB
|
||
|
fcb_parse:
|
||
|
push si
|
||
|
push di
|
||
|
push ax
|
||
|
mov di, bx
|
||
|
inc di
|
||
|
.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:
|
||
|
pop ax
|
||
|
.ret:
|
||
|
pop ax
|
||
|
pop di
|
||
|
pop si
|
||
|
ret
|
||
|
|
||
|
; Print a FCB (for debugging)
|
||
|
; IN BX ptr FCB
|
||
|
fcb_print:
|
||
|
push dx
|
||
|
push cx
|
||
|
push si
|
||
|
mov si, bx
|
||
|
inc si
|
||
|
mov cx, 11
|
||
|
.loop:
|
||
|
lodsb
|
||
|
mov dl, al
|
||
|
call putc
|
||
|
loop .loop
|
||
|
mov dl, 0x26
|
||
|
call putc
|
||
|
.ret:
|
||
|
pop si
|
||
|
pop cx
|
||
|
pop dx
|
||
|
ret
|