; Freddy Offenga, 4/21/2000
+; initmainargs is forcibly included by the C compiler if it encounters a
+; main() function with arguments. Therefore it isn't referenced by the
+; startup code but is nevertheless included in the compiled program when
+; needed.
+
MAXARGS = 16 ; max. amount of arguments in arg. table
CL_SIZE = 64 ; command line buffer size
SPACE = 32 ; SPACE char.
.import __dos_type
.constructor initmainargs,25
+; --------------------------------------------------------------------------
; Get command line
+.segment "INIT"
+
initmainargs:
lda #0
sta __argc
argdos: lda #ATEOL
sta ourcl+CL_SIZE
-
+
; Move SpartaDOS command line to our own buffer
lda DOSVEC
finargs:
lda __argc
- asl
+ asl
tax
lda #0
sta argv,x
stx __argv+1
rts
- .bss
+; --------------------------------------------------------------------------
+; Data
+
+.bss
argv: .res (1 + MAXARGS) * 2