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;
int nrelFiles = 0;
bool verboseExec = FALSE;
char *preOutName;
+bool noXinitOpt = FALSE;
/* uncomment JAMIN_DS390 to always override and use ds390 port
for mcs51 work. This is temporary, for compatibility testing. */
#define OPTION_NO_GCSE "--nogcse"
#define OPTION_SHORT_IS_8BITS "--short-is-8bits"
#define OPTION_TINI_LIBID "--tini-libid"
+#define OPTION_NO_XINIT_OPT "--no-xinit-opt"
static const OPTION
optionsTable[] = {
{ 0, "--tini-libid", NULL,"<nnnn> LibraryID used in -mTININative"},
{ 0, "--protect-sp-update", &options.protect_sp_update,"DS390 - will disable interrupts during ESP:SP updates"},
{ 0, "--parms-in-bank1", &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"},
+ { 0, OPTION_NO_XINIT_OPT, &noXinitOpt, "don't memcpy initialized xram from code"},
/* End of options */
{ 0, NULL }
};
exit (1);
}
+/* Override the default processor with the one specified
+ * on the command line */
+static void
+_setProcessor (char *_processor)
+{
+ port->processor = _processor;
+ fprintf(stderr,"Processor: %s\n",_processor);
+}
+
static void
_validatePorts (void)
{
port = _ports[0];
}
+/* search through the command line options for the processor */
+static void
+_findProcessor (int argc, char **argv)
+{
+ while (argc--)
+ {
+ if (!strncmp (*argv, "-p", 2))
+ {
+ _setProcessor (*argv + 2);
+ return;
+ }
+ argv++;
+ }
+
+ /* no error if processor was not specified. */
+}
+
/*-----------------------------------------------------------------*/
/* printVersionInfo - prints the version info */
/*-----------------------------------------------------------------*/
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 */
werror (W_UNSUPPORTED_MODEL, sz, port->target);
}
-static void
-_setProcessor (char *_processor)
-{
- port->processor = _processor;
- fprintf(stderr,"Processor: %s\n",_processor);
-}
-
/** Gets the string argument to this option. If the option is '--opt'
then for input of '--optxyz' or '--opt xyz' returns xyz.
*/
break;
case 'm':
- /* Used to select the port */
- _setPort (argv[i] + 2);
+ /* Used to select the port. But this has already been done. */
break;
case 'p':
- /* Used to select the processor in port */
- _setProcessor (getStringArg("-p", argv, &i, argc));
+ /* Used to select the processor in port. But this has
+ * already been done. */
break;
case 'c':
/* if debug option is set the open the cdbFile */
if (options.debug && srcFileName)
{
- sprintf (scratchFileName, "%s.cdb", srcFileName);
+ sprintf (scratchFileName, "%s.adb", srcFileName); //JCF: Nov 30, 2002
if ((cdbFile = fopen (scratchFileName, "w")) == NULL)
werror (E_FILE_OPEN_ERR, scratchFileName);
else
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)
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);
/* 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]);
/* Have to set cppoutfilename to something, even if just pre-processing. */
setMainValue ("cppoutfilename", preOutName ? preOutName : "");
-
+
if (options.verbose)
printf ("sdcc: Calling preprocessor...\n");
exit (1);
}
+ /* install atexit handler */
+ atexit(rm_tmpfiles);
+
+ /* Before parsing the command line options, do a
+ * search for the port and processor and initialize
+ * them if they're found. (We can't gurantee that these
+ * will be the first options specified).
+ */
+
_findPort (argc, argv);
+
#ifdef JAMIN_DS390
if (strcmp(port->target, "mcs51") == 0) {
printf("DS390 jammed in A\n");
ds390_jammed = 1;
}
#endif
+
+ _findProcessor (argc, argv);
+
/* Initalise the port. */
if (port->init)
port->init ();
yyparse ();
- if (!fatalError)
- {
- if (TARGET_IS_PIC) {
- /* TSD PIC port hack - if the PIC port option is enabled
- and SDCC is used to generate PIC code, then we will
- generate .asm files in gpasm's format instead of SDCC's
- assembler's format
- */
+ if (fatalError) {
+ // @FIX: Dario Vecchio 03-05-2001
+ if (preOutName) {
+ if (yyin && yyin != stdin)
+ fclose (yyin);
+ unlink (preOutName);
+ Safe_free (preOutName);
+ }
+ // EndFix
+ return 1;
+ }
+
+ if (TARGET_IS_PIC) {
+ /* TSD PIC port hack - if the PIC port option is enabled
+ and SDCC is used to generate PIC code, then we will
+ generate .asm files in gpasm's format instead of SDCC's
+ assembler's format
+ */
#if !OPT_DISABLE_PIC
- picglue ();
+ picglue ();
#endif
- } else {
- glue ();
- }
-
- if (fatalError)
- {
- // @FIX: Dario Vecchio 03-05-2001
- if (preOutName)
- {
- if (yyin && yyin != stdin)
- fclose (yyin);
- unlink (preOutName);
- Safe_free (preOutName);
- }
- // EndFix
- return 1;
- }
- if (!options.c1mode && !noAssemble)
- {
- if (options.verbose)
- printf ("sdcc: Calling assembler...\n");
- assemble (envp);
- }
- }
- else
- {
- // @FIX: Dario Vecchio 03-05-2001
- if (preOutName)
- {
- if (yyin && yyin != stdin)
- fclose (yyin);
- unlink (preOutName);
- Safe_free (preOutName);
- }
- // EndFix
- #if defined (__MINGW32__) || defined (__CYGWIN__) || defined (_MSC_VER)
- rm_tmpfiles();
- #endif
- return 1;
- }
+ }
+ else {
+ glue ();
+ }
+ if (!options.c1mode && !noAssemble)
+ {
+ if (options.verbose)
+ printf ("sdcc: Calling assembler...\n");
+ assemble (envp);
+ }
}
closeDumpFiles();
if (cdbFile)
fclose (cdbFile);
+ if (yyin && yyin != stdin)
+ fclose (yyin);
+
if (preOutName && !options.c1mode)
{
unlink (preOutName);
linkEdit (envp);
}
- if (yyin && yyin != stdin)
- fclose (yyin);
-
return 0;
-
}