ccp: implement dir command

This commit is contained in:
Nero 2022-01-18 20:20:10 +00:00
parent 105183837d
commit f35a4f2170

View File

@ -11,6 +11,17 @@ inlen equ 0x90
banner db "RDOS Console Command Processor",0x0A,0x0D,0x1A banner db "RDOS Console Command Processor",0x0A,0x0D,0x1A
%include "print.inc"
%include "scan.inc"
; eat leftover spaces
; IN ds:si ptr
eatws jmp .l01
.l02 inc si
.l01 cmp byte [si], 0x20
je .l02
ret
prompt mov ax, cs prompt mov ax, cs
mov ds, ax mov ds, ax
mov es, ax mov es, ax
@ -36,6 +47,8 @@ prompt mov ax, cs
mov dx, inbuf mov dx, inbuf
mov ah, 10 mov ah, 10
int 0x21 int 0x21
cmp byte [inbuf+1], 0
je prompt
; parse inbuf into comfcb, buf, fcb1 and fcb2 ; parse inbuf into comfcb, buf, fcb1 and fcb2
; takes no arguments ; takes no arguments
@ -65,26 +78,89 @@ parse mov si, inbuf+2
mov di, fcb2 mov di, fcb2
call lodfn call lodfn
; dump out everything parsed for me to see ; dump out everything parsed for me to see
mov si, comfcb ;mov si, comfcb
call dump ;call dump
mov si, fcb1 ;mov si, fcb1
call dump ;call dump
mov si, fcb2 ;mov si, fcb2
call dump ;call dump
mov si, buf ;mov si, buf
call dump ;call dump
call exec
jmp prompt
; execute, prog in comfcb, args in buf
exec mov bx, ctab
jmp .l02
.l01 add bx, 10
cmp byte [bx], 0
je .ret
.l02 mov si, comfcb+1
mov di, bx
mov cx, 4
repe cmpsw
jne .l01
jmp [bx+8]
.ret mov dx, enoent
mov ah, 9
int 0x21
ret ret
; eat leftover spaces enoent db "no command", 0x0A, 0x0D, "$"
; IN ds:si ptr
eatws jmp .l01
.l02 inc si
.l01 cmp byte [si], 0x20
je .l02
ret
%include "print.inc" ctab db "DIR "
%include "scan.inc" dw c_dir
db 0
c_dir mov di, fcb1+1
cmp byte [di], 0x20
jne .l01
mov ax, '??'
mov cx, 4
rep stosw
.l01 mov di, fcb1+9
cmp byte [di], 0x20
jne .l02
mov al, '?'
mov cx, 3
rep stosb
.l02 mov dx, buf
mov ah, 0x1A
int 0x21
mov ah, 0x11
.loop mov dx, fcb1
int 0x21
test al, al
jnz .ret
mov dl, [buf]
add dl, 0x40
mov ah, 2
int 0x21
mov dl, ':'
int 0x21
mov cx, 8
mov si, buf+1
.l03 lodsb
mov dl, al
int 0x21
loop .l03
mov dl, ' '
int 0x21
mov cx, 3
mov si, buf+9
.l04 lodsb
mov dl, al
int 0x21
loop .l04
mov dl, 0x0A
int 0x21
mov dl, 0x0D
int 0x21
mov ah, 0x12
jmp .loop
.ret ret
section .bss section .bss