MAXARGS = 10
; ProDOS stores the filename in the second half of BASIC's input buffer, so
-; there are 128 characters left. At least 7 characters are necessary for the
-; CALLxxxx:REM so 121 characters may be used before overwriting the ProDOS
-; filename. As we don't want to put further restrictions on the command-line
-; length we reserve those 121 characters terminated by a zero.
+; there are 128 characters left. At least 1 character is necessary for the
+; REM so 127 characters (including the terminating zero) may be used before
+; overwriting the ProDOS filename. As we don't want to further restrict the
+; command-line length we reserve those 127 characters.
-BUF_LEN = 122
+BUF_LEN = 127
BASIC_BUF = $200
FNAM_LEN = $280
FNAM = $281
REM = $B2 ; BASIC token-code
-; Get possible command-line arguments. Goes into the special INIT segment,
+; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run.
- .segment "INIT"
+ .segment "ONCE"
initmainargs:
; destroyed.
ldy #$00
+ sty buffer + BUF_LEN - 1
: lda BASIC_BUF,x
sta buffer,y
inx
stx __argv+1
rts
-; This array is zeroed before initmainargs is called.
-; char* argv[MAXARGS+1] = {FNAM};
-
.data
+; char* argv[MAXARGS+1] = {FNAM};
+
argv: .addr FNAM
.res MAXARGS * 2
- .bss
+ .segment "INIT"
-buffer: .res BUF_LEN
\ No newline at end of file
+buffer: .res BUF_LEN