+2004-02-18 Jesus Calvino-Fraga <jesusc AT ece.ubc.ca>
+
+ * 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 <bernhard AT bernhardheld.de>
* device/include/c8051f320.h: added. Contributed by Maarten Brock.
*/
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
*/
for(j=0, size=0; j<ramlimit; j++)
if(idatamap[j]==fchar) size++;
+ if( (fchar=='S') && (stacksize==0) )
+ {
+ /*Search for the largest space available and use it for stack*/
+ for(j=0, k=0, taxp->a_size=0; j<ramlimit; j++)
+ {
+ if(idatamap[j]==' ')
+ {
+ if((++k)>(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)
*/
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
*/
};
int j;
- if(packflag_and_stacksize)
+ if(packflag)
{
for (j=0; rel2[j][0]!=0; j++)
{
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;
}
}
}
/*
* Link all area addresses.
*/
- if(!packflag_and_stacksize)
+ if(!packflag)
lnkarea();
else
lnkarea2();
if (sflag) /*JCF: memory usage summary output*/
{
- if(!packflag_and_stacksize)
+ if(!packflag)
{
if(summary(areap)) lkexit(1);
}
}
}
- if ((iram_size) && (!packflag_and_stacksize))
+ if ((iram_size) && (!packflag))
iramcheck();
/*
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;
return(0);
case 'a':
- case 'A':
iramsav();
return(0);
" -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
{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*/
{
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<MIN_STACK)
+ if ((int)k<stacksize)
{
sprintf(buff, "Only %d byte%s available for stack.\n",
k, (k==1)?"":"s");
int summary2(struct area * areap)
{
#define EQ(A,B) !as_strcmpi((A),(B))
- #define MIN_STACK 16
char buff[128];
int j, toreturn=0;
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="4">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
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 ~
+<Value>
+\begin_inset LatexCommand \index{-\/-stack-size <Value>}
+
+\end_inset
+
+ Causes the linker to check if there is at minimum <Value> 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
\begin_inset Tabular
<lyxtabular version="3" rows="11" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="17" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="4">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="3">
<features>
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="3">
<features>
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="6" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0(null)">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0(null)">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="2">
<features>
-<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0(null)">
<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
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 */
#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[] = {
#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"},
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)
{
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*/
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);