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:
parent
065b8f2596
commit
467d8ad9c5
34 changed files with 340 additions and 90 deletions
|
@ -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"
|
||||
|
@ -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.
|
||||
|
||||
|
|
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
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
C_OBJS =
|
||||
|
||||
S_OBJS = crt0.o \
|
||||
mainargs.o \
|
||||
systime.o
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
@ -41,13 +41,9 @@
|
|||
|
||||
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.
|
||||
|
||||
|
|
21
libsrc/atmos/mainargs.s
Normal file
21
libsrc/atmos/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
|
||||
|
||||
|
|
@ -40,6 +40,7 @@ OBJS = _scrsize.o \
|
|||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
kernal.o \
|
||||
mainargs.o \
|
||||
mouse.o \
|
||||
randomize.o \
|
||||
revers.o \
|
||||
|
|
|
@ -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.
|
||||
|
|
21
libsrc/c128/mainargs.s
Normal file
21
libsrc/c128/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
|
||||
|
||||
|
|
@ -38,6 +38,7 @@ OBJS = _scrsize.o \
|
|||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
kernal.o \
|
||||
mainargs.o \
|
||||
randomize.o \
|
||||
revers.o
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
21
libsrc/c16/mainargs.s
Normal file
21
libsrc/c16/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
|
||||
|
||||
|
|
@ -39,6 +39,7 @@ OBJS = _scrsize.o \
|
|||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
kernal.o \
|
||||
mainargs.o \
|
||||
mouse.o \
|
||||
randomize.o \
|
||||
revers.o \
|
||||
|
|
|
@ -12,6 +12,7 @@ TIME = $A0 ; 60 HZ clock
|
|||
FNAM_LEN = $B7 ; Length of filename
|
||||
SECADR = $B9 ; Secondary address
|
||||
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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
72
libsrc/c64/mainargs.s
Normal file
72
libsrc/c64/mainargs.s
Normal file
|
@ -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
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ OBJS = _scrsize.o \
|
|||
kplot.o \
|
||||
kscnkey.o \
|
||||
kudtim.o \
|
||||
mainargs.o \
|
||||
mouse.o \
|
||||
peeksys.o \
|
||||
pokesys.o \
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
21
libsrc/cbm510/mainargs.s
Normal file
21
libsrc/cbm510/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
|
||||
|
||||
|
|
@ -37,6 +37,7 @@ OBJS = _scrsize.o \
|
|||
kplot.o \
|
||||
kscnkey.o \
|
||||
kudtim.o \
|
||||
mainargs.o \
|
||||
peeksys.o \
|
||||
pokesys.o \
|
||||
randomize.o \
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
21
libsrc/cbm610/mainargs.s
Normal file
21
libsrc/cbm610/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
|
||||
|
||||
|
|
@ -16,7 +16,14 @@
|
|||
%.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
|
||||
|
|
|
@ -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
|
||||
|
@ -39,16 +39,10 @@
|
|||
|
||||
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.
|
||||
|
|
21
libsrc/geos/devel/mainargs.s
Normal file
21
libsrc/geos/devel/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
|
||||
|
||||
|
|
@ -38,6 +38,7 @@ OBJS = _scrsize.o \
|
|||
kreadst.o \
|
||||
ksetlfs.o \
|
||||
ksetnam.o \
|
||||
mainargs.o \
|
||||
randomize.o \
|
||||
revers.o
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
21
libsrc/pet/mainargs.s
Normal file
21
libsrc/pet/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
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ OBJS = _scrsize.o \
|
|||
ktalk.o \
|
||||
kunlsn.o \
|
||||
kuntlk.o \
|
||||
mainargs.o \
|
||||
randomize.o \
|
||||
revers.o \
|
||||
tgi_mode_table.o
|
||||
|
|
|
@ -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.
|
||||
|
|
21
libsrc/plus4/mainargs.s
Normal file
21
libsrc/plus4/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
|
||||
|
||||
|
|
@ -38,6 +38,7 @@ OBJS = _scrsize.o \
|
|||
kbhit.o \
|
||||
kernal.o \
|
||||
kplot.o \
|
||||
mainargs.o \
|
||||
randomize.o \
|
||||
revers.o
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
21
libsrc/vic20/mainargs.s
Normal file
21
libsrc/vic20/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
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue