From a48a91c8dae3b3714baf31e726f33b0dca4f49f0 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 3 Jun 2019 08:56:39 -0400 Subject: [PATCH] pgm: properly pass shell args in HL --- kernel/pgm.asm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/pgm.asm b/kernel/pgm.asm index ead37ac..9e33deb 100644 --- a/kernel/pgm.asm +++ b/kernel/pgm.asm @@ -35,16 +35,19 @@ pgmShellHook: 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. jp pgmRun .noFile: ld a, SHELL_ERR_IO_ERROR ret ; Loads code in file that FS_PTR is currently pointing at and place it in -; PGM_CODEADDR. Then, jump to PGM_CODEADDR. +; PGM_CODEADDR. Then, jump to PGM_CODEADDR. We expect HL to point to unparsed +; arguments being given to the program. pgmRun: call fsIsValid jr nz, .ioError + push hl ; unparsed args ld ix, FS_HANDLES call fsOpen ld hl, PGM_CODEADDR @@ -53,6 +56,8 @@ pgmRun: ld (hl), a ; Z preserved inc hl ; Z preserved in 16-bit jr z, .loop + + pop hl ; recall args ; ready to jump! jp PGM_CODEADDR