diff --git a/src/ccp.asm b/src/ccp.asm index d17d660..c117201 100644 --- a/src/ccp.asm +++ b/src/ccp.asm @@ -11,6 +11,17 @@ inlen equ 0x90 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 mov ds, ax mov es, ax @@ -36,6 +47,8 @@ prompt mov ax, cs mov dx, inbuf mov ah, 10 int 0x21 + cmp byte [inbuf+1], 0 + je prompt ; parse inbuf into comfcb, buf, fcb1 and fcb2 ; takes no arguments @@ -65,26 +78,89 @@ parse mov si, inbuf+2 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 + ;mov si, comfcb + ;call dump + ;mov si, fcb1 + ;call dump + ;mov si, fcb2 + ;call dump + ;mov si, buf + ;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 - ; eat leftover spaces - ; IN ds:si ptr -eatws jmp .l01 -.l02 inc si -.l01 cmp byte [si], 0x20 - je .l02 - ret +enoent db "no command", 0x0A, 0x0D, "$" -%include "print.inc" -%include "scan.inc" +ctab db "DIR " + 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