From: Alan Cox Date: Fri, 16 Jan 2015 17:36:53 +0000 (+0000) Subject: 6502 lib: Small changes to get us to the point we can link init X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d2b90080bc425e13afb5b10a8bd4701ec64fddfe;p=FUZIX.git 6502 lib: Small changes to get us to the point we can link init Mostly we need strtol as the cc65 runtime one tries to use the wrong isfoo() functions --- diff --git a/Library/libs/Makefile.6502 b/Library/libs/Makefile.6502 index 89a73a9e..0a706a5a 100644 --- a/Library/libs/Makefile.6502 +++ b/Library/libs/Makefile.6502 @@ -54,6 +54,7 @@ SRC_C += system.c time.c tmpnam.c ttyname.c SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c +SRC_C += strtol.c # tty layer SRC_C += tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c SRC_C += cfmakeraw.c cfspeed.c revoke.c diff --git a/Library/libs/crt0_6502.s b/Library/libs/crt0_6502.s index b710bc93..cfdc54e7 100644 --- a/Library/libs/crt0_6502.s +++ b/Library/libs/crt0_6502.s @@ -5,18 +5,21 @@ ; and Ullrich von Bassewitz 2014-08-22, Greg King ; - .import initlib, donelib .import __CODE_SIZE__, __RODATA_SIZE__ .import __DATA_SIZE__, __BSS_SIZE__ .import _exit - .import _environ + .export _environ + .export initmainargs .import _main + .import popax + .import ___stdio_init_vars + + .export __STARTUP__ : absolute = 1; .include "zeropage.inc" -; Place the startup code in a special segment. +.segment "STARTUP" -.segment "STARTUP" jmp start .byte 'F' @@ -30,6 +33,7 @@ .word __BSS_SIZE__ .word 0 + ; ; On entry sp/sp+1 have been set up by the kernel (this has to be ; done in kernel as we might take a signal very early on). Above the @@ -40,14 +44,12 @@ ; for us and we are ready to roll. ; start: -; Call the module constructors. - jsr initlib - ; Push the command-line arguments; and, call main(). ; ; Need to save the environment ptr. The rest of the stack should be ; fine. ; + jsr ___stdio_init_vars lda sp ldx sp+1 clc @@ -56,10 +58,17 @@ start: inx l1: sta _environ stx _environ+1 - ldy #4 + jsr popax ; Pull argv off the stack leaving argc + ldy #2 ; 2 bytes of args jsr _main ; Call the module destructors. This is also the exit() entry. jmp _exit ; exit syscall, AX holds our return code ; for a fastcall return to nowhere. + +initmainargs: ; Hardcoded compiler dumbness + rts + + .bss +_environ: .word 0