char *
aopLiteralLong (value * val, int offset, int size)
{
- char *rs;
union {
float f;
unsigned char c[4];
v >>= (offset * 8);
switch (size) {
case 1:
- tsprintf (buffer, "!immedbyte", (unsigned int) v & 0xff);
+ tsprintf (buffer, sizeof(buffer),
+ "!immedbyte", (unsigned int) v & 0xff);
break;
case 2:
- tsprintf (buffer, "!immedword", (unsigned int) v & 0xffff);
+ tsprintf (buffer, sizeof(buffer),
+ "!immedword", (unsigned int) v & 0xffff);
break;
default:
/* Hmm. Too big for now. */
assert (0);
}
- rs = Safe_calloc (1, strlen (buffer) + 1);
- return strcpy (rs, buffer);
+ return Safe_strdup (buffer);
}
/* PENDING: For now size must be 1 */
/* it is type float */
fl.f = (float) floatFromVal (val);
#ifdef _BIG_ENDIAN
- tsprintf (buffer, "!immedbyte", fl.c[3 - offset]);
+ tsprintf (buffer, sizeof(buffer),
+ "!immedbyte", fl.c[3 - offset]);
#else
- tsprintf (buffer, "!immedbyte", fl.c[offset]);
+ tsprintf (buffer, sizeof(buffer),
+ "!immedbyte", fl.c[offset]);
#endif
- rs = Safe_calloc (1, strlen (buffer) + 1);
- return strcpy (rs, buffer);
+ return Safe_strdup (buffer);
}
/*-----------------------------------------------------------------*/
// create a new "XINIT (CODE)" symbol, that will be emitted later
newSym=copySymbol (sym);
SPEC_OCLS(newSym->etype)=xinit;
- sprintf (newSym->name, "__xinit_%s", sym->name);
- sprintf (newSym->rname,"__xinit_%s", sym->rname);
+ SNPRINTF (newSym->name, sizeof(newSym->name), "__xinit_%s", sym->name);
+ SNPRINTF (newSym->rname, sizeof(newSym->rname), "__xinit_%s", sym->rname);
SPEC_CONST(newSym->etype)=1;
SPEC_STAT(newSym->etype)=1;
resolveIvalSym(newSym->ival);
resolveIvalSym (sym->ival);
printIval (sym, sym->type, sym->ival, out);
noAlloc--;
+ // if sym->ival is a string, WE don't need it anymore
+ if (IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
+ list2val(sym->ival)->sym->isstrlit) {
+ freeStringSymbol(list2val(sym->ival)->sym);
+ }
}
else {
/* allocate space */
/* only if the main function exists */
if (!(mainf = findSymWithLevel (SymbolTab, mainf)))
{
- if (!options.cc_only && !noAssemble)
+ if (!options.cc_only && !noAssemble && !options.c1mode)
werror (E_NO_MAIN);
return;
}
/* now put it all together into the assembler file */
/* create the assembler file name */
- if (!options.c1mode)
+ /* -o option overrides default name? */
+ if ((noAssemble || options.c1mode) && fullDstFileName)
{
- sprintf (scratchFileName, srcFileName);
- strcat (scratchFileName, port->assembler.file_ext);
+ strncpyz (scratchFileName, fullDstFileName, PATH_MAX);
}
else
{
- strcpy (scratchFileName, options.out_name);
+ strncpyz (scratchFileName, dstFileName, PATH_MAX);
+ strncatz (scratchFileName, port->assembler.file_ext, PATH_MAX);
}
if (!(asmFile = fopen (scratchFileName, "w")))
copyFile (asmFile, sfrbit->oFile);
/*JCF: Create the areas for the register banks*/
- if( TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51 )
+ if(port->general.glue_up_main &&
+ (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51))
{
if(RegBankUsed[0]||RegBankUsed[1]||RegBankUsed[2]||RegBankUsed[3])
{
}
/* initialise the stack pointer. JCF: aslink takes care of the location */
- fprintf (asmFile, "\tmov\tsp,#__start__stack\n"); /* MOF */
+ fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n"); /* MOF */
fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
fprintf (asmFile, "\tmov\ta,dpl\n");