From: Alan Cox Date: Thu, 21 May 2015 22:09:07 +0000 (+0100) Subject: Makefile: add a "nostdio" crt0 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=77583581381987b14a4db205cbd0ff68d7e146aa;p=FUZIX.git Makefile: add a "nostdio" crt0 --- diff --git a/Library/libs/Makefile b/Library/libs/Makefile index deb83767..ce3f4680 100644 --- a/Library/libs/Makefile +++ b/Library/libs/Makefile @@ -14,6 +14,8 @@ ASM_OPT = -l -o -s LINKER_OPT = -m -i -o SRC_CRT0 = crt0$(PLATFORM).s OBJ_CRT0 = $(SRC_CRT0:.s=.rel) +SRC_CRT0NS = crt0nostdio$(PLATFORM).s +OBJ_CRT0NS = $(SRC_CRT0NS:.s=.rel) SRC_ASM = enter.s OBJ_ASM = $(SRC_ASM:.s=.rel) SRC_C = __argv.c abort.c asctime.c assert.c atexit.c @@ -64,7 +66,7 @@ OBJ_C = $(SRC_C:.c=.rel) OBJ_HARD = $(SRC_HARD:.c=.rel) OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) -all: syslib$(PLATFORM).lib crt0$(PLATFORM).rel +all: syslib$(PLATFORM).lib crt0$(PLATFORM).rel crt0nostdio$(PLATFORM).rel libc.l:%.l:$(OBJ_ALL) ls $(OBJ_ALL) > libc.l @@ -94,6 +96,9 @@ $(OBJ_ASM):%.rel: %.s $(OBJ_CRT0):%.rel: %.s $(ASM) $(ASM_OPT) $@ $(@:.rel=.s) +$(OBJ_CRT0NS):%.rel: %.s + $(ASM) $(ASM_OPT) $@ $(@:.rel=.s) + $(OBJ_C):%.rel: %.c $(CC) $(CC_OPT) $(@:.rel=.c) diff --git a/Library/libs/crt0nostdio.s b/Library/libs/crt0nostdio.s new file mode 100644 index 00000000..1ed5c7d5 --- /dev/null +++ b/Library/libs/crt0nostdio.s @@ -0,0 +1,80 @@ + .module crt0 + + .area _CODE + .area _HOME + .area _CONST + ; The _GS can be blown away after startup. We don't yet + ; but we should do FIXME + .area _GSINIT + .area _GSFINAL + .area _INITIALIZED + .area _BSEG + .area _DATA + .area _BSS + ; note that the binary builder moves the initialized data + ; from initializer + .area _INITIALIZER + + .globl _main + .globl _exit + .globl _environ + .globl ___argv + + .globl s__DATA + .globl l__DATA + .globl s__INITIALIZED + + .area _CODE + +; start at 0x100 +start: jp start2 + .db 'F' + .db 'Z' + .db 'X' + .db '1' + +; +; Borrowed idea from UMZIX - put the info in known places then +; we can write "size" tools +; +; This is confusing. SDCC doesn't produce a BSS, instead it +; produces an INITIALIZED (which everyone else calls DATA) and a +; DATA which everyone else would think of as BSS. +; +; FIXME: we need to automate the load page setting +; + .db 0x01 ; page to load at + .dw 0 ; chmem ("0 - 'all'") + .dw s__INITIALIZED ; gives us code size info + .dw s__DATA ; gives us data size info + .dw l__DATA ; bss size info + .dw 0 ; spare + +start2: ld hl, #l__DATA - 1 ; work around linker limit + ld b, h + ld c, l + ld hl, #s__DATA + ld de, #s__DATA+1 + ld (hl), #0 + ldir + call gsinit + + ld hl, #4 + add hl, sp + ld (_environ), hl + pop de ; argc + pop hl ; argv + push hl + ld (___argv), hl ; needed for stuff like err() + push de + ld hl, #_exit ; return vector + push hl + jp _main ; go + + .area _GSINIT +gsinit: + .area _GSFINAL + ret + + .area _DATA +_environ: .dw 0