Implement filename->FCB parsing and command line reading
This commit is contained in:
parent
0bd59dd252
commit
105183837d
94
src/ccp.asm
Normal file
94
src/ccp.asm
Normal file
@ -0,0 +1,94 @@
|
||||
fcb1 equ 0x5C
|
||||
fcb2 equ 0x6C
|
||||
buf equ 0x80
|
||||
|
||||
; length of input buffer
|
||||
inlen equ 0x90
|
||||
|
||||
org 0x100
|
||||
|
||||
jmp prompt
|
||||
|
||||
banner db "RDOS Console Command Processor",0x0A,0x0D,0x1A
|
||||
|
||||
prompt mov ax, cs
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
; print newline
|
||||
mov dl, 0x0A
|
||||
mov ah, 2
|
||||
int 0x21
|
||||
mov dl, 0x0D
|
||||
int 0x21
|
||||
; query current drive
|
||||
mov ah, 25
|
||||
int 0x21
|
||||
; drivenum to chr
|
||||
mov dl, al
|
||||
add dl, 0x41
|
||||
; print drive and prompt chr
|
||||
mov ah, 2
|
||||
int 0x21
|
||||
mov dl, '>'
|
||||
int 0x21
|
||||
; read string
|
||||
mov byte [inbuf], inlen
|
||||
mov dx, inbuf
|
||||
mov ah, 10
|
||||
int 0x21
|
||||
|
||||
; parse inbuf into comfcb, buf, fcb1 and fcb2
|
||||
; takes no arguments
|
||||
; parse off command name
|
||||
parse mov si, inbuf+2
|
||||
mov di, comfcb
|
||||
call lodfn
|
||||
; trim spaces
|
||||
call eatws
|
||||
; calculate length of cmdline
|
||||
mov cx, inbuf+2
|
||||
add cl, [inbuf+1]
|
||||
adc ch, 0
|
||||
sub cx, si
|
||||
; move into default position at 0x80
|
||||
mov [buf], cl
|
||||
mov di, buf+1
|
||||
rep movsb
|
||||
mov al, 0x0D
|
||||
stosb
|
||||
; parse fcb1
|
||||
mov si, buf+1
|
||||
mov di, fcb1
|
||||
call lodfn
|
||||
; parse fcb2
|
||||
call eatws
|
||||
mov di, fcb2
|
||||
call lodfn
|
||||
; dump out everything parsed for me to see
|
||||
mov si, comfcb
|
||||
call dump
|
||||
mov si, fcb1
|
||||
call dump
|
||||
mov si, fcb2
|
||||
call dump
|
||||
mov si, buf
|
||||
call dump
|
||||
ret
|
||||
|
||||
; eat leftover spaces
|
||||
; IN ds:si ptr
|
||||
eatws jmp .l01
|
||||
.l02 inc si
|
||||
.l01 cmp byte [si], 0x20
|
||||
je .l02
|
||||
ret
|
||||
|
||||
%include "print.inc"
|
||||
%include "scan.inc"
|
||||
|
||||
section .bss
|
||||
|
||||
inbuf resb inlen
|
||||
|
||||
; FCB for the COM file
|
||||
comfcb resb 37
|
70
src/scan.inc
70
src/scan.inc
@ -61,3 +61,73 @@ lodnum xor di, di
|
||||
mul bx
|
||||
add di, ax
|
||||
jmp .loop
|
||||
|
||||
lodfn mov ah, al
|
||||
mov al, [si+1]
|
||||
cmp al, ':'
|
||||
jne .nam
|
||||
.drv mov dx, 0x0100
|
||||
call .read
|
||||
inc si
|
||||
; adjust capital letter to number
|
||||
and byte [es:di], 0x1F
|
||||
.nam mov dx, 0x0901
|
||||
call .read
|
||||
mov al, [si]
|
||||
cmp al, '.'
|
||||
jne .ext
|
||||
inc si
|
||||
.ext mov dx, 0x0C09
|
||||
call .read
|
||||
.ret ret
|
||||
; read a padded string
|
||||
.read mov al, [si]
|
||||
mov bh, 0
|
||||
cmp dl, dh
|
||||
jnc .ret
|
||||
call ucase
|
||||
call fatchr
|
||||
jz .fill
|
||||
mov bl, dl
|
||||
mov [es:di+bx], al
|
||||
inc dl
|
||||
inc si
|
||||
jmp .read
|
||||
; fill padding with spaces
|
||||
.fill mov al, 0x20
|
||||
.cfill cmp dl, dh
|
||||
jnc .ret
|
||||
mov bl, dl
|
||||
mov [es:di+bx], al
|
||||
inc dl
|
||||
jmp .fill
|
||||
|
||||
; is valid char for FAT filename
|
||||
; IN al character
|
||||
; OUT al char
|
||||
; zf clear if valid
|
||||
fatchr push cx
|
||||
push bx
|
||||
mov bl, al
|
||||
mov bh, 0
|
||||
mov cl, 3
|
||||
sar bx, cl
|
||||
mov ch, [cs:.vtab+bx]
|
||||
mov cl, al
|
||||
and cl, 7
|
||||
shr ch, cl
|
||||
test ch, 1
|
||||
pop bx
|
||||
pop cx
|
||||
ret
|
||||
; character validity map
|
||||
; 256 bits for each char
|
||||
; 1 = allowed in fat name
|
||||
.vtab dw 0x0000,0x0000 ; 00-1F control chars all forbidden
|
||||
dw 0x23FA,0x03FF ; 20-3F special and digits
|
||||
dw 0xFFFF,0xC7FF ; 40-5F uppercase
|
||||
dw 0x0001,0x6800 ; 60-7F lowercase
|
||||
dw 0x0000,0x0000 ; 80-9F
|
||||
dw 0x0000,0x0000 ; A0-BF
|
||||
dw 0x0000,0x0000 ; C0-DF
|
||||
dw 0x0000,0x0000 ; E0-FF
|
||||
|
Loading…
Reference in New Issue
Block a user