diff --git a/kernel/pgm.asm b/kernel/pgm.asm index 188fc2b..fea8aa4 100644 --- a/kernel/pgm.asm +++ b/kernel/pgm.asm @@ -19,30 +19,18 @@ .equ PGM_RAMEND PGM_HANDLE+FS_HANDLE_SIZE ; Routine suitable to plug into SHELL_CMDHOOK. HL points to the full cmdline. -; We can mutate it because the shell doesn't do anything with it afterwards. +; which has been processed to replace the first ' ' with a null char. pgmShellHook: call fsIsOn jr nz, .noFile - ; first first space and replace it with zero so that we have something - ; suitable for fsFindFN. - push hl ; remember beginning - ld a, ' ' - call findchar - jr nz, .noarg ; if we have no arg, we want DE to point to the - ; null char. Also, we have no replacement to - ; make - ; replace space with nullchar - xor a - ld (hl), a - inc hl ; make HL point to the beginning of args -.noarg: - ex de, hl ; DE now points to the beginning of args or to \0 if - ; no args - pop hl ; HL points to cmdname, properly null-terminated + ; (HL) is suitable for a direct fsFindFN call call fsFindFN jr nz, .noFile - ; We have a file! Load it and run it. - ex de, hl ; but first, make HL point to unparsed args. + ; We have a file! Advance HL to args + xor a + call findchar + inc hl ; beginning of args + ; Alright, ready to run! jp pgmRun .noFile: ld a, SHELL_ERR_IO_ERROR diff --git a/kernel/shell.asm b/kernel/shell.asm index d0d8b1c..ca99de4 100644 --- a/kernel/shell.asm +++ b/kernel/shell.asm @@ -100,9 +100,23 @@ shellParse: push hl push ix + ; Before looking for a suitable command, let's make the cmd line more + ; usable by replacing the first ' ' with a null char. This way, cmp is + ; easy to make. + push hl ; --> lvl 1 + ld a, ' ' + call findchar + jr z, .hasArgs + ; no arg, (HL) is zero to facilitate processing later, add a second + ; null next to that one to indicate unambiguously that we have no args. + inc hl +.hasArgs: + xor a + ld (hl), a + pop hl ; <-- lvl 1, beginning of cmd + ld de, shellCmdTbl - ld a, SHELL_CMD_COUNT - ld b, a + ld b, SHELL_CMD_COUNT .loop: push de ; we need to keep that table entry around... @@ -131,13 +145,9 @@ shellParse: call intoDE ; Jump from the table entry to the cmd addr. ; advance the HL pointer to the beginning of the args. - ld a, ' ' + xor a call findchar - or a ; end of string? don't increase HL - jr z, .noargs - inc hl ; char after space - -.noargs: + inc hl ; beginning of args ; Now, let's have DE point to the argspecs ld a, 4 call addDE diff --git a/recipes/sms/romasm/glue.asm b/recipes/sms/romasm/glue.asm index 1caf235..0671511 100644 --- a/recipes/sms/romasm/glue.asm +++ b/recipes/sms/romasm/glue.asm @@ -123,7 +123,7 @@ f1PutC: jp fsPutC edCmd: - .db "eded", 0b1001, 0, 0 + .db "ed", 0, 0, 0b1001, 0, 0 push hl \ pop ix ld l, (ix) ld h, (ix+1)