From 8533ea221c13a98c6b4a6b10ef7d31ecd3ae5f6d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 27 Feb 2018 23:56:14 -0600 Subject: [PATCH] When argc==0, argv should be a valid pointer and argv[0] should be NULL. This is normal for S16 programs or inits, and can happen with shell executables in certain cases like when being run from Prizm. --- cc.asm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cc.asm b/cc.asm index 7b13afb..74c490f 100644 --- a/cc.asm +++ b/cc.asm @@ -172,8 +172,8 @@ TAB equ 9 TAB key code plb plx ply - pea 0 make room for argc, argv - pea 0 + pea targv|-16 make room for argc, argv + per targv (default argv = ptr to targv) pea 0 phy put the return addr back on the stack phx @@ -190,9 +190,12 @@ TAB equ 9 TAB key code lda cLine if cLine == 0 then ora cLine+2 - jeq rtl exit + bne lb0 + stz targv argv[0] = NULL + stz targv+2 + brl rtl exit - add4 cLine,#8 skip the shell identifier +lb0 add4 cLine,#8 skip the shell identifier ldx #0 count the arguments txy short M @@ -348,8 +351,8 @@ start ds 2 start of the command line string plb plx ply - pea 0 set argc, argv to 0 - pea 0 + pea targv|-16 set argc = 0, argv to point to targv + per targv pea 0 phy put the return addr back on the stack phx @@ -357,8 +360,13 @@ start ds 2 start of the command line string stz ~ExitList no exit routines, yet stz ~ExitList+2 + stz targv argv[0] = NULL + stz targv+2 + plb return rtl + +targv ds 4 end ****************************************************************