Close

Reviewing SDCC integration

A project log for eForth for cheap STM8S gadgets

Turn cheap modules from AliExpress into interactive development kits!

thomasThomas 11/01/2016 at 08:430 Comments

Before I pushed the optimized code to GitHub, I had a second look at how to play nice with SDCC variable initialization. There is very little linker documentation (which is hidden in the SDCC binary) and its way of allocating memory. Fortunately a lot can be learned from the SDCC source code!

One of the problems I had to work around is to figure out where the INITIALIZER area ends unless I figure out how to use the local symbols s_INITIALIZER and l_INITIALIZER in forth.asm.

My current work-around is to get the address of the INITIALIZER area in forth.asm and hope that it's the last file to allocate space there. Maybe I can influence this by putting forth.rel always at the end of the SDCC call in the Makefile.

;       nvdat  ( -- )
;       Data about Non Volatile Memory 
	.dw	LINK
        
        .ifne   WORDS_LINKCOMP
        LINK =  .
	.db	(5)
	.ascii	"nvdat"
        .endif
NVDAT:
        CALL    DOVAR
        .dw     LASTN            ; Init for LASTN
        .dw     END_SDCC_FLASH   ; init for USRCPNVM (free Flash starts here) 
        .dw     USRPOOL          ; Next RAM cell for indirect variables  
        .endif
         
;===============================================================
	LASTN	=	LINK	;last name defined

 	.area CODE
	.area INITIALIZER
        END_SDCC_FLASH = .
	.area CABS (ABS)

Discussions