]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/getargs.s
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / atari / getargs.s
index f8f24793750891d7e8f164d2b7b4dc4fc43831ac..da7fd73aa8a79ab48b900cec5d6892154efbb223 100644 (file)
@@ -2,6 +2,11 @@
 
 ; 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.
@@ -12,8 +17,11 @@ SPACE        = 32            ; SPACE char.
        .import         __dos_type
        .constructor    initmainargs,25
 
+; --------------------------------------------------------------------------
 ; Get command line
 
+.segment        "INIT"
+
 initmainargs:
        lda     #0
        sta     __argc
@@ -23,14 +31,16 @@ initmainargs:
 
        lda     __dos_type      ; which DOS?
        cmp     #ATARIDOS
+       beq     nargdos         ; DOS does not support arguments
+       cmp     #MYDOS
        bne     argdos          ; DOS supports arguments
-       rts
+nargdos:rts
 
 ; Initialize ourcl buffer
 
 argdos:        lda     #ATEOL
        sta     ourcl+CL_SIZE
-        
+
 ; Move SpartaDOS command line to our own buffer
 
        lda     DOSVEC
@@ -110,7 +120,7 @@ eopar:
 
 finargs:
        lda     __argc
-       asl
+       asl           
        tax
        lda     #0
        sta     argv,x
@@ -121,7 +131,10 @@ finargs:
        stx     __argv+1
        rts
 
-       .bss
+; --------------------------------------------------------------------------
+; Data
+
+.bss
 
 argv:  .res    (1 + MAXARGS) * 2