]> git.sur5r.net Git - cc65/commitdiff
Added routines to handle command line params
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 10 Mar 2003 21:21:46 +0000 (21:21 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 10 Mar 2003 21:21:46 +0000 (21:21 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2012 b7a2c559-68d2-44c3-8de9-860c34a00d81

34 files changed:
libsrc/apple2/Makefile
libsrc/apple2/crt0.s
libsrc/apple2/mainargs.s [new file with mode: 0644]
libsrc/atmos/Makefile
libsrc/atmos/crt0.s
libsrc/atmos/mainargs.s [new file with mode: 0644]
libsrc/c128/Makefile
libsrc/c128/crt0.s
libsrc/c128/mainargs.s [new file with mode: 0644]
libsrc/c16/Makefile
libsrc/c16/crt0.s
libsrc/c16/mainargs.s [new file with mode: 0644]
libsrc/c64/Makefile
libsrc/c64/c64.inc
libsrc/c64/crt0.s
libsrc/c64/mainargs.s [new file with mode: 0644]
libsrc/cbm510/Makefile
libsrc/cbm510/crt0.s
libsrc/cbm510/mainargs.s [new file with mode: 0644]
libsrc/cbm610/Makefile
libsrc/cbm610/crt0.s
libsrc/cbm610/mainargs.s [new file with mode: 0644]
libsrc/geos/devel/Makefile
libsrc/geos/devel/crt0.s
libsrc/geos/devel/mainargs.s [new file with mode: 0644]
libsrc/pet/Makefile
libsrc/pet/crt0.s
libsrc/pet/mainargs.s [new file with mode: 0644]
libsrc/plus4/Makefile
libsrc/plus4/crt0.s
libsrc/plus4/mainargs.s [new file with mode: 0644]
libsrc/vic20/Makefile
libsrc/vic20/crt0.s
libsrc/vic20/mainargs.s [new file with mode: 0644]

index be8fe57e81f37f7c1e8a9fd24345a606faff526a..88372e21b25f62e885217532a85d12e9e0d78d88 100644 (file)
@@ -29,6 +29,7 @@ OBJS= _scrsize.o      \
        ctype.o         \
        cvline.o        \
        kbhit.o         \
+        mainargs.o      \
         randomize.o     \
        read.o          \
        revers.o        \
index b3cfb55c990617ab687ad3dfba2d14cbc603dd57..5b9edce225c2b31cb6d99e738e187c6aba1550bb 100644 (file)
@@ -8,7 +8,7 @@
        .import         initlib, donelib
        .import         zerobss, push0
                .import         __STARTUP_LOAD__, __BSS_LOAD__  ; Linker generated
-       .import         _main
+       .import         callmain
 
         .include        "zeropage.inc"
        .include        "apple2.inc"
@@ -33,7 +33,7 @@
 
                ldx     #zpspace-1
 L1:    lda     sp,x
-       sta     zpsave,x        ; Save the zero page locations we need
+       sta     zpsave,x        ; Save the zero page locations we need
        dex
                bpl     L1
 
@@ -44,12 +44,12 @@ L1: lda     sp,x
 ; Save system stuff and setup the stack
 
                tsx
-               stx     spsave          ; Save the system stack ptr
+               stx     spsave          ; Save the system stack ptr
 
        lda     MEMSIZE
        sta     sp
        lda     MEMSIZE+1
-               sta     sp+1            ; Set argument stack ptr
+               sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
@@ -64,13 +64,9 @@ L1:  lda     sp,x
 
        ;;      sta     USEROM
 
-; Pass an empty command line
+; Push arguments and call main()
 
-       jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+       jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
@@ -78,7 +74,7 @@ _exit:        jsr     donelib
 
 ; Restore system stuff
 
-       lda     #$ff            ; Reset text mode
+       lda     #$ff            ; Reset text mode
        sta     TEXTTYP
 
        ldx     spsave
diff --git a/libsrc/apple2/mainargs.s b/libsrc/apple2/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 8932789372c166c902e8de23eeba09c771951d7d..7a07b6c52fc43e51d148cde843a18eca20fbbb5e 100644 (file)
@@ -20,6 +20,7 @@
 C_OBJS =
 
 S_OBJS  =       crt0.o          \
+                mainargs.o      \
                 systime.o
 
 #--------------------------------------------------------------------------
index c386b9c4b50cae9f65243c244ba3beeae37ac6d7..cb1b5a14eabd6a45ddf9638f4583fad8e0f9de33 100644 (file)
@@ -8,7 +8,7 @@
 
        .export         _exit
        .import         initlib, donelib
-       .import         push0, _main, zerobss
+       .import         push0, callmain, zerobss
        .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
 
         .importzp       sp
 
        jsr     initlib
 
-; Pass an empty command line
+; Push arguments and call main()
 
-               jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/atmos/mainargs.s b/libsrc/atmos/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 36310200b0a3ddcc3f87eb3f13feed7a55c586f8..ee074146943888386c0110c28fc59aa7693e92af 100644 (file)
@@ -40,6 +40,7 @@ OBJS =        _scrsize.o              \
        joy_stddrv.o            \
        kbhit.o                 \
         kernal.o               \
+        mainargs.o              \
        mouse.o                 \
         randomize.o            \
         revers.o               \
index 2e09a3f73159b7cf0b072a1410e33b2fce1698a7..324e1a5de6a5a38b5c711910d3c42dc983990cae 100644 (file)
@@ -7,7 +7,7 @@
        .export         _exit
        .import         condes, initlib, donelib
        .import         zerobss
-       .import         push0, _main
+       .import         push0, callmain
         .import         RESTOR, BSOUT, CLRCH
        .import         __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
        .import         __RAM_START__, __RAM_SIZE__
@@ -108,13 +108,9 @@ L1:        lda     sp,x
        stx     IRQVec+1
        cli
 
-; Pass an empty command line
+; Push arguments and call main()
 
-NoIRQ1:        jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+NoIRQ1:        jsr     callmain
 
 ; Back from main (this is also the _exit entry). Reset the IRQ vector if
 ; we chained it.
diff --git a/libsrc/c128/mainargs.s b/libsrc/c128/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 3fa69d4c4c308001febb477bc0be28c239e148f4..45645c96d466a2ef23bd7a41c3be5f32d435c237 100644 (file)
@@ -38,6 +38,7 @@ OBJS =        _scrsize.o      \
        joy_stddrv.o    \
        kbhit.o         \
         kernal.o        \
+        mainargs.o      \
         randomize.o     \
         revers.o
 
index d040f4e5373dcdd9dec04c5a3ebb58dc08716359..8a63537b0cdd8a5d287ba7672d9eeb979e699424 100644 (file)
@@ -9,7 +9,7 @@
 
        .export         _exit
        .import         initlib, donelib
-       .import         push0, _main, zerobss
+       .import         push0, callmain, zerobss
         .import         MEMTOP, RESTOR, BSOUT, CLRCH
 
         .include        "zeropage.inc"
@@ -75,13 +75,9 @@ MemOk:       stx     sp
 
        jsr     initlib
 
-; Pass an empty command line
+; Push arguments and call main()
 
-               jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/c16/mainargs.s b/libsrc/c16/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 30cceb14b4bd415bd4287b0235ccde98a7974952..5e8d1bcfe716e1cfbfe24d62b3eb2bf247df1976 100644 (file)
@@ -39,6 +39,7 @@ OBJS =        _scrsize.o              \
        joy_stddrv.o            \
                kbhit.o                 \
         kernal.o                \
+        mainargs.o              \
                mouse.o                 \
         randomize.o             \
         revers.o                \
index 913842fa3616354ec8092e27fc0a11f584fad757..e93872f938d4b0785046d4cab86cd92c6f737a6c 100644 (file)
@@ -11,7 +11,8 @@ ST            = $90           ; IEC status byte
 TIME            = $A0           ; 60 HZ clock
 FNAM_LEN       = $B7           ; Length of filename
 SECADR         = $B9           ; Secondary address
-DEVNUM         = $BA           ; Device number
+DEVNUM         = $BA           ; Device number     
+FNAM            = $BB           ; Pointer to filename
 KEY_COUNT              = $C6           ; Number of keys in input buffer
 RVS             = $C7           ; Reverse flag
 CURS_FLAG      = $CC           ; 1 = cursor off
index 4c441d513b288fe3766d7b48c528c6d272063f61..17166f4d273b19d72144f7f04432e2e76e5c5bd8 100644 (file)
@@ -7,7 +7,7 @@
        .export         _exit
        .import         initlib, donelib
                .import         zerobss, push0
-       .import         _main
+       .import         callmain
         .import         RESTOR, BSOUT, CLRCH
        .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
 
@@ -81,13 +81,9 @@ L1:  lda     sp,x
 
        jsr     initlib
 
-; Pass an empty command line
+; Push arguments and call main
 
-               jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+        jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/c64/mainargs.s b/libsrc/c64/mainargs.s
new file mode 100644 (file)
index 0000000..4a34e41
--- /dev/null
@@ -0,0 +1,72 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main.
+; Based on code from Stefan A. Haubenthal, <polluks@web.de>
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+        .include        "c64.inc"
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+; Setup a pointer to our argv vector
+
+        lda     #<argv
+        sta     __argv
+        lda     #>argv
+        sta     __argv+1
+
+; Save the last filename as argument #0. Since the buffer we're copying into
+; is zeroed out, we don't need to add a NUL character.
+
+        ldy     FNAM_LEN
+        cpy     #16+1
+        bcc     L0
+        ldy     #16             ; Limit the length
+L0:     dey
+L1:     lda     (FNAM),y
+        sta     argv0,y
+        dey
+        bpl     L1
+        inc     __argc          ; __argc = 1
+
+; Find argument in BASIC buffer, if found, use it as arg #1
+
+        ldy     #0
+L2:     lda     $200,y
+        beq     L9
+        iny
+        cmp     #$8F            ; REM token
+        bne     L2
+        sty     argv+2          ; Store offset
+        ldy     #>$200
+        sty     argv+3
+        inc     __argc          ; argc = 2
+
+; Done
+
+L9:     rts
+
+.endproc
+
+
+;---------------------------------------------------------------------------
+; Data
+
+.data
+
+argv:   .word   argv0           ; Pointer to program name
+        .word   $0000           ; Optional second argument
+        .word   $0000           ; Last vector must always be NULL
+
+.bss
+argv0:  .res    17              ; Program name
+
+
index 60cb8f6c463b5777fd5ac3373621086d5028664e..4609aeb6a509b9bb151dd21c3553ae7f69acfd59 100644 (file)
@@ -48,6 +48,7 @@ OBJS =        _scrsize.o      \
                kplot.o         \
        kscnkey.o       \
        kudtim.o        \
+        mainargs.o      \
        mouse.o         \
        peeksys.o       \
        pokesys.o       \
index 6b6ca16764942f1393501f6bb52603f4fc0de4de..2296106a0e8a6efc60426bfd22b5fe653158a489 100644 (file)
@@ -7,7 +7,7 @@
        .export         _exit
 
        .import         _clrscr, initlib, donelib
-       .import         push0, _main
+       .import         push0, callmain
        .import         __CHARRAM_START__, __CHARRAM_SIZE__, __VIDRAM_START__
         .import         __EXTZP_RUN__, __EXTZP_SIZE__
        .import         __BSS_RUN__, __BSS_SIZE__
@@ -282,11 +282,6 @@ ccopy2:    lda     __VIDRAM_START__,y
 
                jsr     initlib
 
-; Create the (empty) command line for the program
-
-               jsr     push0           ; argc
-               jsr     push0           ; argv
-
 ; Execute the program code
 
        jmp     Start
@@ -378,10 +373,9 @@ Start:
 
        cli
 
-; Call the user code
+; Push arguments and call main()
 
-               ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/cbm510/mainargs.s b/libsrc/cbm510/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 3facda076b844496bb0951cda75e32a4bd5d9e86..6856f764ad55ea8dc55c22e9668407ab46c89b83 100644 (file)
@@ -37,6 +37,7 @@ OBJS =        _scrsize.o      \
                kplot.o         \
        kscnkey.o       \
        kudtim.o        \
+        mainargs.o      \
        peeksys.o       \
        pokesys.o       \
         randomize.o     \
index f2298bcd9e504f6f0bb8339970f32a403affcd3c..65fdf81e3252acf03f1f7426efaa27b33844d7d1 100644 (file)
@@ -9,7 +9,7 @@
        .exportzp       ktab2, ktab3, ktab4, time, RecvBuf, SendBuf
 
        .import         initlib, donelib
-       .import         push0, _main
+       .import         push0, callmain
        .import         __BSS_RUN__, __BSS_SIZE__
        .import         irq, nmi
                .import         k_irq, k_nmi, PLOT, UDTIM, SCNKEY
@@ -214,11 +214,6 @@ Z4:
 
        jsr     initlib
 
-; Create the (empty) command line for the program
-
-               jsr     push0           ; argc
-               jsr     push0           ; argv
-
 ; Execute the program code
 
        jmp     Start
@@ -293,10 +288,9 @@ Start:
 
        cli
 
-; Call the user code
+; Push arguments and call main()
 
-               ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/cbm610/mainargs.s b/libsrc/cbm610/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index b763ac5eb793a4eaf3f511e30374533295f65f23..a5287174c4809e83d9b41e936580f39a4c9a184d 100644 (file)
 %.tgi: %.o ../../runtime/zeropage.o
        @$(LD) -t module -o $@ $^
 
-S_OBJS = crt0.o extzp.o oserror.o oserrlist.o randomize.o fio_module.o tgi_mode_table.o
+S_OBJS = crt0.o                \
+          extzp.o               \
+          fio_module.o          \
+          mainargs.o            \
+          oserror.o             \
+          oserrlist.o           \
+          randomize.o           \
+          tgi_mode_table.o
 
 #--------------------------------------------------------------------------
 # Drivers
index 75ad670d314e1ea285fa9755c4b929e76ded78a4..76e9c8ef6904e8725f09bcde47b361883b2c95bd 100644 (file)
@@ -8,7 +8,7 @@
        .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
        .import         initlib, donelib
                .import         pushax
-       .import         _main
+       .import         callmain
        .import         _MainLoop, _EnterDeskTop
        .import         zerobss
        .importzp       sp
 
        jsr     initlib
 
-; Pass an empty command line
-
-       lda     #0
-       tax
-       jsr     pushax          ; argc
-       jsr     pushax          ; argv
+; Push arguments and call main()
 
        cli
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry which must be called
 ; explicitly by the code.
diff --git a/libsrc/geos/devel/mainargs.s b/libsrc/geos/devel/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index bcfb680d3b40153a678de9a7a2ab3b6ee60f1feb..a09bde862baca2ed6e29a4ee64686c6d970aa405 100644 (file)
@@ -38,6 +38,7 @@ OBJS =        _scrsize.o      \
         kreadst.o       \
         ksetlfs.o       \
         ksetnam.o       \
+        mainargs.o      \
         randomize.o    \
        revers.o
 
index fb65973ecd5e4586e478bbe051c794494016b1b9..c3cebc77464f60ba7340f6a59a8328d756ff4005 100644 (file)
@@ -7,7 +7,7 @@
        .export         _exit
        .import         initlib, donelib
                .import         zerobss, push0
-       .import         _main
+       .import         callmain
         .import         CLRCH, BSOUT
 
         .include        "zeropage.inc"
@@ -70,13 +70,9 @@ L1:  lda     sp,x
 
        jsr     initlib
 
-; Pass an empty command line
+; Push arguments and call main()
 
-       jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+       jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/pet/mainargs.s b/libsrc/pet/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index df257b1e8cb9526ef5f9efcbcabd1987d28859db..e453c9e4b5a96570609d041ade8a1b9a6dce91a8 100644 (file)
@@ -60,6 +60,7 @@ OBJS =        _scrsize.o      \
         ktalk.o         \
         kunlsn.o        \
         kuntlk.o        \
+        mainargs.o      \
         randomize.o     \
         revers.o        \
        tgi_mode_table.o
index a2e33413d57e11e01a01a4f16265ce5d78a00394..3146e36742a6fab4720e3392a5e53babef0d1a8a 100644 (file)
@@ -8,7 +8,7 @@
         .export         brk_jmp
 
        .import         condes, initlib, donelib
-       .import         push0, _main, zerobss
+       .import         push0, callmain, zerobss
        .import         __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
 
         .include        "zeropage.inc"
@@ -99,13 +99,9 @@ L1:  lda     sp,x
        stx     IRQVec+1
        cli
 
-; Pass an empty command line
+; Push arguments and call main()
 
-NoIRQ1: jsr            push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+NoIRQ1: jsr            callmain
 
 ; Back from main (this is also the _exit entry). Reset the IRQ vector if
 ; we chained it.
diff --git a/libsrc/plus4/mainargs.s b/libsrc/plus4/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+
index 7baf2b69cc23ec3cd9ce6791371cde71a1bb1428..1be2fae722b11ca75530bfb72b619ebe7cd76137 100644 (file)
@@ -38,6 +38,7 @@ OBJS =        _scrsize.o      \
        kbhit.o         \
         kernal.o        \
         kplot.o         \
+        mainargs.o      \
         randomize.o     \
        revers.o
 
@@ -66,4 +67,4 @@ clean:
 zap:   clean
        @rm -f $(EMDS) $(JOYS) $(TGIS)
 
-                    
+
index ca3ff2f496bbb28c508aa8ec8e766ce7f5af5695..03a3bbc92693991eb51960e7c1cf4f8474c25d8e 100644 (file)
@@ -7,7 +7,7 @@
        .export         _exit
        .import         initlib, donelib
                .import         zerobss, push0
-       .import         _main
+       .import         callmain
         .import         RESTOR, BSOUT, CLRCH
        .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
 
@@ -75,13 +75,9 @@ L1:  lda     sp,x
 
        jsr     initlib
 
-; Pass an empty command line
+; Push arguments and call main()
 
-               jsr     push0           ; argc
-       jsr     push0           ; argv
-
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
+               jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
diff --git a/libsrc/vic20/mainargs.s b/libsrc/vic20/mainargs.s
new file mode 100644 (file)
index 0000000..ebe6d03
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+       .constructor    initmainargs, 24
+               .import         __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc   initmainargs
+
+        rts
+
+.endproc
+
+