]> git.gag.com Git - fw/sdcc/commitdiff
Delegates data and stack allocation to aslink. Creates areas for register
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 4 Sep 2002 09:50:24 +0000 (09:50 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 4 Sep 2002 09:50:24 +0000 (09:50 +0000)
banks.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2095 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglobl.h
src/SDCCglue.c
src/SDCCmain.c
src/SDCCmem.c

index b7e45e4a7aff0b103ca734c7f83881bbd5e1ad83..4bfc4c3294e122930a5a414bc139382585a681db 100644 (file)
@@ -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 */
index 795b8a4ad048c2435877fc8dff51ad07a7061eff..17ebae4660b069ec9f4ace0fccab76512626d65f 100644 (file)
@@ -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");
index a2e89e51dd0a8af657595ee34c90dcef0770ad61..f6c8526578ac32b74ec98778ea7914846c0f05e9 100644 (file)
@@ -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]);
index c98b2bd0f9ab538305821005d907fb901e95be15..b1e192e0169790a8ed915d7e3451b97fc4d00d47 100644 (file)
@@ -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 */