From: jesusc Date: Wed, 18 Feb 2004 17:57:54 +0000 (+0000) Subject: Added options --stack-size and --pack-iram X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=8179aae7c86bde07e4e0b70b4f8ed4e7f0be74f1;p=fw%2Fsdcc Added options --stack-size and --pack-iram git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3206 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 9566a913..1640d9d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-02-18 Jesus Calvino-Fraga + + * as/mcs51/aslink.h, as/mcs51/lkarea.c, as/mcs51/lkdata.c, as/mcs51/lkmain.c, + as/mcs51/lkmem.c, src/SDCCglob.h, src/SDCCmain.c: added options --stack-size and + --pack-iram. + * doc/sdccman.lyx: described options --stack-size and --pack-iram. + 2004-02-17 Bernhard Held * device/include/c8051f320.h: added. Contributed by Maarten Brock. diff --git a/as/mcs51/aslink.h b/as/mcs51/aslink.h index ff4cb8da..ace467ef 100644 --- a/as/mcs51/aslink.h +++ b/as/mcs51/aslink.h @@ -578,7 +578,9 @@ extern int mflag; /* Map output flag */ extern int sflag; /* JCF: Memory usage output flag */ -extern int packflag_and_stacksize; /* Pack data memory flag +extern int packflag; /* Pack data memory flag + */ +extern int stacksize; /* Pack data memory flag */ extern int jflag; /* NoICE output flag */ diff --git a/as/mcs51/lkarea.c b/as/mcs51/lkarea.c index 9646d30f..693b5d49 100644 --- a/as/mcs51/lkarea.c +++ b/as/mcs51/lkarea.c @@ -658,6 +658,23 @@ void lnksect2 (struct area *tap, int rloc) for(j=0, size=0; ja_size=0; j(int)taxp->a_size) taxp->a_size=k; + } + else + { + k=0; + } + } + stacksize=taxp->a_size; + } + /*If more space required, release the previously allocated areax in internal RAM and search for a bigger one*/ if((int)taxp->a_size>size) diff --git a/as/mcs51/lkdata.c b/as/mcs51/lkdata.c index 1840ee79..660c22af 100644 --- a/as/mcs51/lkdata.c +++ b/as/mcs51/lkdata.c @@ -55,7 +55,9 @@ int mflag; /* Map output flag */ int sflag; /* JCF: Memory usage output flag */ -int packflag_and_stacksize=0; /* JCF: Pack internal memory flag +int packflag=0; /* JCF: Pack internal memory flag + */ +int stacksize=0; /* JCF: Stack size */ int aflag; /* Overlapping area warning flag */ diff --git a/as/mcs51/lkmain.c b/as/mcs51/lkmain.c index b51857ce..fd11cf39 100644 --- a/as/mcs51/lkmain.c +++ b/as/mcs51/lkmain.c @@ -108,7 +108,7 @@ void Areas51 (void) }; int j; - if(packflag_and_stacksize) + if(packflag) { for (j=0; rel2[j][0]!=0; j++) { @@ -135,7 +135,7 @@ void Areas51 (void) else if (!strcmp(ap->a_id, "BSEG_BYTES")) { ap->a_addr=0x20; ap->a_type=1; } else if (!strcmp(ap->a_id, "SSEG")) { - if(packflag_and_stacksize>1) ap->a_axp->a_size=packflag_and_stacksize; + if(stacksize) ap->a_axp->a_size=stacksize; } } } @@ -340,7 +340,7 @@ char *argv[]; /* * Link all area addresses. */ - if(!packflag_and_stacksize) + if(!packflag) lnkarea(); else lnkarea2(); @@ -371,7 +371,7 @@ char *argv[]; if (sflag) /*JCF: memory usage summary output*/ { - if(!packflag_and_stacksize) + if(!packflag) { if(summary(areap)) lkexit(1); } @@ -381,7 +381,7 @@ char *argv[]; } } - if ((iram_size) && (!packflag_and_stacksize)) + if ((iram_size) && (!packflag)) iramcheck(); /* @@ -825,10 +825,19 @@ parse() case 'Y': unget(getnb()); - /*The stack segment default size is 16 bytes. Use -Yxx for xx bytes*/ - packflag_and_stacksize=(ip && *ip)?expr(0):16; + packflag=1; break; + case 'A': + unget(getnb()); + if (ip && *ip) + { + stacksize=expr(0); + if(stacksize>256) stacksize=256; + else if(stacksize<0) stacksize=0; + } + return(0); + case 'j': case 'J': jflag = 1; @@ -892,7 +901,6 @@ parse() return(0); case 'a': - case 'A': iramsav(); return(0); @@ -1367,7 +1375,8 @@ char *usetxt[] = { " -v [xram-size] Check for external RAM overflow", " -w [code-size] Check for code overflow", " -y Generate memory usage summary file[mem]", - " -Y [stack-size] Pack internal ram and allocate space for stack", + " -Y Pack internal ram", + " -A [stack-size] Allocate space for stack", "End:", " -e or null line terminates input", 0 diff --git a/as/mcs51/lkmem.c b/as/mcs51/lkmem.c index 9e63c868..bf4c4ef8 100644 --- a/as/mcs51/lkmem.c +++ b/as/mcs51/lkmem.c @@ -73,12 +73,14 @@ int summary(struct area * areap) {0x7f, 0, 128, "DATA", 0x0020}, {0, 0, 128, "TOTAL:", 0x0000} }; - + _Mem IRam= {0xff, 0, 128, "INDIRECT RAM", 0x0080}; _Mem Stack={0xff, 0, 1, "STACK", 0x0000}; _Mem XRam= {0xffff, 0, 65536, "EXTERNAL RAM", 0x0100}; _Mem Rom= {0xffff, 0, 65536, "ROM/EPROM/FLASH", 0x0200}; - + + if(stacksize==0) stacksize=MIN_STACK; + if(rflag) /*For the DS390*/ { XRam.Max=0x1000000; /*24 bits*/ @@ -285,7 +287,7 @@ int summary(struct area * areap) { for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++); fprintf(of, " with %d bytes available\n", k); - if (k - - - - + + + + \begin_inset Text @@ -5888,6 +5888,54 @@ status Collapsed Causes the linker to check if the code memory usage is within limits of the given value. +\layout List +\labelwidthstring 00.00.0000 + + +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-stack-size +\series default +\SpecialChar ~ + +\begin_inset LatexCommand \index{-\/-stack-size } + +\end_inset + + Causes the linker to check if there is at minimum bytes for stack. +\layout List +\labelwidthstring 00.00.0000 + + +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-pack-iram +\series default +\SpecialChar ~ + +\begin_inset LatexCommand \index{-\/-pack-iram} + +\end_inset + + Causes the linker use unused register banks for data variables or stack. \layout Subsection DS390 / DS400 Options @@ -12253,8 +12301,8 @@ For signed & unsigned int (16 bit) and long (32 bit) variables, division, \begin_inset Tabular - - + + \begin_inset Text @@ -12547,8 +12595,8 @@ SDCC supports IEEE (single precision 4 bytes) floating point numbers.The \begin_inset Tabular - - + + \begin_inset Text @@ -13870,8 +13918,8 @@ The compiler creates the following #defines \begin_inset Tabular - - + + \begin_inset Text @@ -14875,8 +14923,8 @@ PIC16 port defines the following preprocessor macros while translating a \begin_inset Tabular - - + + \begin_inset Text @@ -14937,10 +14985,10 @@ PIC16 port uses the following directories for searching header files and \begin_inset Tabular - - - - + + + + \begin_inset Text @@ -15159,9 +15207,9 @@ Memory model affects the default size of pointers within the source. \begin_inset Tabular - - - + + + \begin_inset Text @@ -15311,9 +15359,9 @@ large \begin_inset Tabular - - - + + + \begin_inset Text @@ -15411,8 +15459,8 @@ Return values from functions are placed to the appropriate registers following \begin_inset Tabular - - + + \begin_inset Text @@ -17323,7 +17371,7 @@ Documentation \begin_inset Tabular - + diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 5ef744e0..687d9075 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -226,6 +226,8 @@ struct options int tini_libid; /* library ID for TINI */ int protect_sp_update; /* DS390 - will disable interrupts during ESP:SP updates */ int parms_in_bank1; /* DS390 - use reg bank1 to pass parameters */ + int stack_size; /* MCS51/DS390 - Tells the linker to allocate this space for stack */ + int pack_iram; /* MCS51/DS390 - Tells the linker to pack variables in internal ram */ /* starting address of the segments */ int xstack_loc; /* initial location of external stack */ int stack_loc; /* initial value of internal stack pointer */ diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 59f27632..5c6bddaf 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -124,6 +124,8 @@ char buffer[PATH_MAX * 2]; #define OPTION_PRINT_SEARCH_DIRS "--print-search-dirs" #define OPTION_MSVC_ERROR_STYLE "--vc" #define OPTION_USE_STDOUT "--use-stdout" +#define OPTION_STACK_SIZE "--stack-size" +#define OPTION_PACK_IRAM "--pack-iram" static const OPTION optionsTable[] = { @@ -218,6 +220,8 @@ optionsTable[] = { #endif #if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51 { 0, "--parms-in-bank1", &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"}, + { 0, OPTION_STACK_SIZE, NULL,"MCS51/DS390 - Tells the linker to allocate this space for stack"}, + { 0, OPTION_PACK_IRAM, &options.pack_iram,"MCS51/DS390 - Tells the linker to pack variables in internal ram"}, #endif { 0, OPTION_NO_XINIT_OPT, &options.noXinitOpt, "don't memcpy initialized xram from code"}, { 0, OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"}, @@ -908,6 +912,12 @@ parseCmdLine (int argc, char **argv) options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i, argc); continue; } + + if (strcmp (argv[i], OPTION_STACK_SIZE) == 0) + { + options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, &i, argc); + continue; + } if (strcmp (argv[i], OPTION_XRAM_LOC) == 0) { @@ -1307,6 +1317,8 @@ linkEdit (char **envp) else /*For all the other ports. Including pics???*/ { fprintf (lnkfile, "-myux%c\n", (options.out_fmt ? 's' : 'i')); + if(options.pack_iram) + fprintf (lnkfile, "-Y\n"); } if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80)) /*Not for the z80, gbz80*/ @@ -1315,6 +1327,10 @@ linkEdit (char **envp) if (options.iram_size) fprintf (lnkfile, "-a 0x%04x\n", options.iram_size); + /* if stack size specified*/ + if(options.stack_size) + fprintf (lnkfile, "-A 0x%02x\n", options.stack_size); + /* if xram size specified */ if (options.xram_size_set) fprintf (lnkfile, "-v 0x%04x\n", options.xram_size);