From b933b387e5365c4486d15cccb67da8b981217b33 Mon Sep 17 00:00:00 2001 From: jesusc Date: Wed, 4 Sep 2002 09:50:24 +0000 Subject: [PATCH] Delegates data and stack allocation to aslink. Creates areas for register banks. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2095 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCglobl.h | 1 + src/SDCCglue.c | 26 +++++++++++++++++--------- src/SDCCmain.c | 16 ++++++++++++---- src/SDCCmem.c | 2 ++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index b7e45e4a..4bfc4c32 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -273,6 +273,7 @@ extern int xstackPtr; /* external stack pointer SDCC.y */ extern int reentrant; /* /X flag has been sent SDCC.y */ extern char buffer[]; /* general buffer SDCCgen.c */ extern int currRegBank; /* register bank being used SDCCgens.c */ +extern int RegBankUsed[4]; /* JCF: register banks used SDCCmain.c */ extern struct symbol *currFunc; /* current function SDCCgens.c */ extern int cNestLevel; /* block nest level SDCCval.c */ extern int currBlockno; /* sequentail block number */ diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 795b8a4a..17ebae46 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -1503,6 +1503,22 @@ glue (void) fprintf (asmFile, "; special function bits \n"); fprintf (asmFile, "%s", iComments2); copyFile (asmFile, sfrbit->oFile); + + /*JCF: Create the areas for the register banks*/ + if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3]) + { + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; overlayable register banks \n"); + fprintf (asmFile, "%s", iComments2); + if(RegBankUsed[0]) + fprintf (asmFile, "\t.area REG_BANK_0\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[1]||options.parms_in_bank1) + fprintf (asmFile, "\t.area REG_BANK_1\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[2]) + fprintf (asmFile, "\t.area REG_BANK_2\t(REL,OVR,DATA)\n\t.ds 8\n"); + if(RegBankUsed[3]) + fprintf (asmFile, "\t.area REG_BANK_3\t(REL,OVR,DATA)\n\t.ds 8\n"); + } /* copy the data segment */ fprintf (asmFile, "%s", iComments2); @@ -1605,15 +1621,7 @@ glue (void) (unsigned int) options.xdata_loc & 0xff); } - /* initialise the stack pointer */ - /* if the user specified a value then use it */ - if (options.stack_loc) - fprintf (asmFile, "\tmov\tsp,#%d\n", options.stack_loc & 0xff); - else - /* no: we have to compute it */ - if (!options.stackOnData && maxRegBank <= 3) - fprintf (asmFile, "\tmov\tsp,#%d\n", ((maxRegBank + 1) * 8) - 1); - else + /* initialise the stack pointer. JCF: aslink takes care of the location */ fprintf (asmFile, "\tmov\tsp,#__start__stack\n"); /* MOF */ fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n"); diff --git a/src/SDCCmain.c b/src/SDCCmain.c index a2e89e51..f6c85265 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -56,6 +56,7 @@ char *srcFileName; /* source file name with the .c stripped */ char *moduleName; /* module name is srcFilename stripped of any path */ const char *preArgv[128]; /* pre-processor arguments */ int currRegBank = 0; +int RegBankUsed[4]={1, 0, 0, 0}; /*JCF: Reg Bank 0 used by default*/ struct optimize optimize; struct options options; char *VersionString = SDCC_VERSION_STR; @@ -478,7 +479,7 @@ setDefaultOptions () options.stack_loc = 0; /* stack pointer initialised to 0 */ options.xstack_loc = 0; /* xternal stack starts at 0 */ options.code_loc = 0; /* code starts at 0 */ - options.data_loc = 0x0030; /* data starts at 0x0030 */ + options.data_loc = 0; /* JCF: By default let the linker locate data */ options.xdata_loc = 0; options.idata_loc = 0x80; options.genericPtr = 1; /* default on */ @@ -1139,8 +1140,8 @@ linkEdit (char **envp) exit (1); } - /* now write the options */ - fprintf (lnkfile, "-mux%c\n", (options.out_fmt ? 's' : 'i')); + /* now write the options. JCF: added option 'y' */ + fprintf (lnkfile, "-myux%c\n", (options.out_fmt ? 's' : 'i')); /* if iram size specified */ if (options.iram_size) @@ -1159,7 +1160,9 @@ linkEdit (char **envp) WRITE_SEG_LOC (CODE_NAME, options.code_loc); /* data segment start */ - WRITE_SEG_LOC (DATA_NAME, options.data_loc); + if(options.data_loc){ /*JCF: If zero, the linker chooses the best place for data*/ + WRITE_SEG_LOC (DATA_NAME, options.data_loc); + } /* xdata start */ WRITE_SEG_LOC (XDATA_NAME, options.xdata_loc); @@ -1172,6 +1175,11 @@ linkEdit (char **envp) /* bit segment start */ WRITE_SEG_LOC (BIT_NAME, 0); + /* JCF: stack start */ + if(options.stack_loc) { + WRITE_SEG_LOC ("SSEG", options.stack_loc & 0xff); + } + /* add the extra linker options */ for (i = 0; linkOptions[i]; i++) fprintf (lnkfile, "%s\n", linkOptions[i]); diff --git a/src/SDCCmem.c b/src/SDCCmem.c index c98b2bd0..b1e192e0 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -844,6 +844,8 @@ allocVariables (symbol * symChain) /* if register bank specified then update maxRegBank */ if (maxRegBank < FUNC_REGBANK (csym->type)) maxRegBank = FUNC_REGBANK (csym->type); + /*JCF: Mark the register bank as used*/ + RegBankUsed[FUNC_REGBANK(csym->type)]=1; } /* if this is a extern variable then change the */ -- 2.47.2