ccp: implement type command

This commit is contained in:
Nero 2022-01-18 22:22:01 +00:00
parent f35a4f2170
commit ea732be8ec
2 changed files with 59 additions and 5 deletions

View File

@ -49,11 +49,21 @@ prompt mov ax, cs
int 0x21
cmp byte [inbuf+1], 0
je prompt
mov dl, 0x0A
mov ah, 2
int 0x21
mov dl, 0x0D
int 0x21
; parse inbuf into comfcb, buf, fcb1 and fcb2
; takes no arguments
; clear out fcb area, dosbox seems to have troubles with leftovers
parse mov di, fcb1
mov cx, buf-fcb1+0x80
mov al, 0
rep stosb
; parse off command name
parse mov si, inbuf+2
mov si, inbuf+2
mov di, comfcb
call lodfn
; trim spaces
@ -110,10 +120,10 @@ enoent db "no command", 0x0A, 0x0D, "$"
ctab db "DIR "
dw c_dir
db "TYPE "
dw c_type
db 0
c_dir mov di, fcb1+1
cmp byte [di], 0x20
jne .l01
@ -129,7 +139,7 @@ c_dir mov di, fcb1+1
.l02 mov dx, buf
mov ah, 0x1A
int 0x21
mov ah, 0x11
mov ah, 0x11 ; find first
.loop mov dx, fcb1
int 0x21
test al, al
@ -158,10 +168,51 @@ c_dir mov di, fcb1+1
int 0x21
mov dl, 0x0D
int 0x21
mov ah, 0x12
mov ah, 0x12 ; find next
jmp .loop
.ret ret
; set dta
c_type mov dx, buf
mov ah, 0x1A
int 0x21
; open file
mov dx, fcb1
mov ah, 0x0f ; fcb open
int 0x21
; fail
test al, al
jnz .err
; place eof marker to read in err case
.loop mov byte [buf], 0x1A
; read a record
mov dx, fcb1
mov ah, 0x14 ; fcb seq read
int 0x21
; set up string read
mov si, buf
mov cx, 0x80
.l02 lodsb
; break on eof or error
cmp al, 0x1A
je .ret
; never write null bytes
mov dl, al
mov ah, 2
int 0x21
loop .l02
jmp .loop
.ret mov dx, fcb1
mov ah, 0x10
int 0x21
ret
; communicate failure to user
.err mov dx, .errmsg
mov ah, 9
int 0x21
ret
.errmsg db "no file", 0x0A,0x0D,"$"
section .bss
inbuf resb inlen

View File

@ -63,6 +63,9 @@ lodnum xor di, di
jmp .loop
lodfn mov ah, al
; set drive byte to default
mov byte [es:di], 0
; check if there is a drvspec
mov al, [si+1]
cmp al, ':'
jne .nam