Added routines to handle command line params
git-svn-id: svn://svn.cc65.org/cc65/trunk@2012 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -29,6 +29,7 @@ OBJS= _scrsize.o \
|
||||
ctype.o \
|
||||
cvline.o \
|
||||
kbhit.o \
|
||||
mainargs.o \
|
||||
randomize.o \
|
||||
read.o \
|
||||
revers.o \
|
||||
|
||||
@@ -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
|
||||
|
||||
21
libsrc/apple2/mainargs.s
Normal file
21
libsrc/apple2/mainargs.s
Normal file
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user