-------------------------------------------------------------------------*/
#include "common.h"
-#include "asm.h"
#include <time.h>
#include "newalloc.h"
#include <fcntl.h>
if (!val) {
// assuming we have been warned before
- val=constVal("0");
+ val = constCharVal (0);
}
/* if it is a float then it gets tricky */
/* otherwise it is fairly simple */
if (!IS_FLOAT (val->type)) {
- unsigned long v = (unsigned long) floatFromVal (val);
+ unsigned long v = ulFromVal (val);
v >>= (offset * 8);
switch (size) {
case 1:
- tsprintf (buffer, sizeof(buffer),
+ tsprintf (buffer, sizeof(buffer),
"!immedbyte", (unsigned int) v & 0xff);
break;
case 2:
- tsprintf (buffer, sizeof(buffer),
+ tsprintf (buffer, sizeof(buffer),
"!immedword", (unsigned int) v & 0xffff);
break;
default:
/* it is type float */
fl.f = (float) floatFromVal (val);
#ifdef WORDS_BIGENDIAN
- tsprintf (buffer, sizeof(buffer),
+ tsprintf (buffer, sizeof(buffer),
"!immedbyte", fl.c[3 - offset]);
#else
- tsprintf (buffer, sizeof(buffer),
+ tsprintf (buffer, sizeof(buffer),
"!immedbyte", fl.c[offset]);
#endif
return Safe_strdup (buffer);
/*-----------------------------------------------------------------*/
/* emitRegularMap - emit code for maps with no special cases */
/*-----------------------------------------------------------------*/
-static void
+static void
emitRegularMap (memmap * map, bool addPublics, bool arFlag)
{
symbol *sym;
else
dbuf_tprintf (&map->oBuf, "\t!area\n", map->sname);
}
-
+
for (sym = setFirstItem (map->syms); sym;
sym = setNextItem (map->syms))
{
continue;
/* for bitvar locals and parameters */
- if (!arFlag && !sym->allocreq && sym->level
+ if (!arFlag && !sym->allocreq && sym->level
&& !SPEC_ABSA (sym->etype)) {
continue;
}
}
dbuf_printf (&map->oBuf, "%s$%d$%d", sym->name, sym->level, sym->block);
}
-
+
/* if it has an initial value then do it only if
it is a global variable */
if (sym->ival && sym->level == 0) {
ival = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
sym->name);
}
ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
eBBlockFromiCode (iCodeFromAst (ival));
allocInfo = 1;
}
- }
+ }
}
/* if it has an absolute address then generate
if (IS_STATIC (sym->etype) || sym->level)
dbuf_tprintf (&map->oBuf, "!slabeldef\n", sym->rname);
else
- dbuf_tprintf (&map->oBuf, "!labeldef\n", sym->rname);
+ dbuf_tprintf (&map->oBuf, "!labeldef\n", sym->rname);
dbuf_tprintf (&map->oBuf, "\t!ds\n", (unsigned int) size & 0xffff);
}
sym->ival = NULL;
}
expr = list2expr (ilist);
-
+
if (!expr)
goto wrong;
-
+
/* try it the old way first */
if ((val = constExprValue (expr, FALSE)))
return val;
-
+
/* ( ptr + constant ) */
if (IS_AST_OP (expr) &&
(expr->opval.op == '+' || expr->opval.op == '-') &&
expr->right,
expr->opval.op);
}
-
+
/* (char *)&a */
if (IS_AST_OP(expr) && expr->opval.op==CAST &&
IS_AST_OP(expr->right) && expr->right->opval.op=='&') {
/*-----------------------------------------------------------------*/
/* printChar - formats and prints a characater string with DB */
/*-----------------------------------------------------------------*/
-void
+void
printChar (struct dbuf_s * oBuf, char *s, int plen)
{
int i;
/*-----------------------------------------------------------------*/
/* return the generic pointer high byte for a given pointer type. */
/*-----------------------------------------------------------------*/
-int
+int
pointerTypeToGPByte (const int p_type, const char *iname, const char *oname)
{
switch (p_type)
case POINTER:
return GPTYPE_NEAR;
case GPOINTER:
- werror (E_CANNOT_USE_GENERIC_POINTER,
- iname ? iname : "<null>",
+ werror (E_CANNOT_USE_GENERIC_POINTER,
+ iname ? iname : "<null>",
oname ? oname : "<null>");
exit (1);
case FPOINTER:
/*-----------------------------------------------------------------*/
/* printPointerType - generates ival for pointer type */
/*-----------------------------------------------------------------*/
-void
+void
_printPointerType (struct dbuf_s * oBuf, const char *name)
{
if (options.model == MODEL_FLAT24)
/*-----------------------------------------------------------------*/
/* printPointerType - generates ival for pointer type */
/*-----------------------------------------------------------------*/
-void
+void
printPointerType (struct dbuf_s * oBuf, const char *name)
{
_printPointerType (oBuf, name);
/*-----------------------------------------------------------------*/
/* printGPointerType - generates ival for generic pointer type */
/*-----------------------------------------------------------------*/
-void
+void
printGPointerType (struct dbuf_s * oBuf, const char *iname, const char *oname,
const unsigned int type)
{
/*-----------------------------------------------------------------*/
/* printIvalType - generates ival for int/char */
/*-----------------------------------------------------------------*/
-void
+void
printIvalType (symbol *sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf)
{
value *val;
if (!(val = list2val (ilist))) {
// assuming a warning has been thrown
- val=constVal("0");
+ val = constCharVal (0);
}
if (val->type != type) {
val = valCastLiteral(type, floatFromVal(val));
}
-
+
switch (getSize (type)) {
case 1:
if (!val)
unsigned long ival = 0;
int size =0;
-
+
do {
unsigned long i;
val = list2val(lilist);
if (size) {
if (SPEC_BLEN(lsym->etype) > 8) {
- size += ((SPEC_BLEN (lsym->etype) / 8) +
+ size += ((SPEC_BLEN (lsym->etype) / 8) +
(SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
}
} else {
- size = ((SPEC_BLEN (lsym->etype) / 8) +
+ size = ((SPEC_BLEN (lsym->etype) / 8) +
(SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
}
- i = (unsigned long)floatFromVal(val);
+ i = ulFromVal(val);
i <<= SPEC_BSTR (lsym->etype);
ival |= i;
if (! ( lsym->next &&
/*-----------------------------------------------------------------*/
/* printIvalStruct - generates initial value for structures */
/*-----------------------------------------------------------------*/
-void
+void
printIvalStruct (symbol * sym, sym_link * type,
initList * ilist, struct dbuf_s * oBuf)
{
if (SPEC_STRUCT (type)->type == UNION) {
printIval (sym, sflds->type, iloop, oBuf);
- iloop = iloop->next;
+ iloop = iloop ? iloop->next : NULL;
} else {
for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
if (IS_BITFIELD(sflds->type)) {
/*-----------------------------------------------------------------*/
/* printIvalChar - generates initital value for character array */
/*-----------------------------------------------------------------*/
-int
+int
printIvalChar (symbol * sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf, char *s)
{
value *val;
printIval (sym, type->next, iloop, oBuf);
}
}
-
+
if (DCL_ELEM(type)) {
// pad with zeros if needed
if (size<DCL_ELEM(type)) {
/*-----------------------------------------------------------------*/
/* printIvalFuncPtr - generate initial value for function pointers */
/*-----------------------------------------------------------------*/
-void
+void
printIvalFuncPtr (sym_link * type, initList * ilist, struct dbuf_s * oBuf)
{
value *val;
if (!val) {
// an error has been thrown already
- val=constVal("0");
+ val = constCharVal (0);
}
if (IS_LITERAL(val->etype)) {
/*-----------------------------------------------------------------*/
/* printIvalCharPtr - generates initial values for character pointers */
/*-----------------------------------------------------------------*/
-int
+int
printIvalCharPtr (symbol * sym, sym_link * type, value * val, struct dbuf_s * oBuf)
{
int size = 0;
/* PENDING: this is _very_ mcs51 specific, including a magic
number...
- It's also endin specific.
+ It's also endian specific.
*/
size = getSize (type);
}
if (port->little_endian) {
dbuf_printf (oBuf, "\t.byte %s,%s,%s\n",
- aopLiteral (val, 0),
+ aopLiteral (val, 0),
aopLiteral (val, 1),
aopLiteral (val, 2));
} else {
dbuf_printf (oBuf, "\t.byte %s,%s,%s\n",
- aopLiteral (val, 2),
+ aopLiteral (val, 2),
aopLiteral (val, 1),
aopLiteral (val, 0));
}
}
if (port->little_endian) {
dbuf_printf (oBuf, "\t.byte %s,%s,%s,%s\n",
- aopLiteral (val, 0),
- aopLiteral (val, 1),
+ aopLiteral (val, 0),
+ aopLiteral (val, 1),
aopLiteral (val, 2),
aopLiteral (val, 3));
} else {
dbuf_printf (oBuf, "\t.byte %s,%s,%s,%s\n",
- aopLiteral (val, 3),
- aopLiteral (val, 2),
+ aopLiteral (val, 3),
+ aopLiteral (val, 2),
aopLiteral (val, 1),
aopLiteral (val, 0));
}
/*-----------------------------------------------------------------*/
/* printIvalPtr - generates initial value for pointers */
/*-----------------------------------------------------------------*/
-void
+void
printIvalPtr (symbol * sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf)
{
value *val;
switch (getSize (type))
{
case 1:
- dbuf_tprintf (oBuf, "\t!db !constbyte\n", (unsigned int) floatFromVal (val) & 0xff);
+ dbuf_tprintf (oBuf, "\t!db !constbyte\n", (unsigned int) ulFromVal (val) & 0xff);
break;
case 2:
if (port->use_dw_for_init)
/*-----------------------------------------------------------------*/
/* printIval - generates code for initial value */
/*-----------------------------------------------------------------*/
-void
+void
printIval (symbol * sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf)
{
sym_link *itype;
-
+
/* if structure then */
if (IS_STRUCT (type))
{
if (ilist->type!=INIT_NODE) {
// or a 1-element list
if (ilist->init.deep->next) {
- werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar",
sym->name);
} else {
ilist=ilist->init.deep;
/*-----------------------------------------------------------------*/
/* emitStaticSeg - emitcode for the static segment */
/*-----------------------------------------------------------------*/
-void
+void
emitStaticSeg (memmap * map, struct dbuf_s * oBuf)
{
symbol *sym;
(sym->localof ? sym->localof->name : "-null-"));
dbuf_printf (oBuf, "%s$%d$%d", sym->name, sym->level, sym->block);
}
-
+
/* if it has an absolute address and no initializer */
if (SPEC_ABSA (sym->etype) && !sym->ival)
{
if (options.debug)
dbuf_printf (oBuf, " == 0x%04x\n", SPEC_ADDR (sym->etype));
-
+
dbuf_printf (oBuf, "%s\t=\t0x%04x\n",
sym->rname,
SPEC_ADDR (sym->etype));
{
if (options.debug)
dbuf_printf (oBuf, " == .\n");
-
+
/* if it has an initial value */
if (sym->ival)
{
dbuf_tprintf (oBuf, "\t!org\n", SPEC_ADDR (sym->etype));
}
dbuf_printf (oBuf, "%s:\n", sym->rname);
- noAlloc++;
+ ++noAlloc;
resolveIvalSym (sym->ival, sym->type);
printIval (sym, sym->type, sym->ival, oBuf);
- noAlloc--;
- /* if sym is a simple string and sym->ival is a string,
+ --noAlloc;
+ /* if sym is a simple string and sym->ival is a string,
WE don't need it anymore */
if (IS_ARRAY(sym->type) && IS_CHAR(sym->type->next) &&
IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
else {
/* allocate space */
int size = getSize (sym->type);
-
+
if (size==0) {
werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE,sym->name);
}
/*-----------------------------------------------------------------*/
/* emitMaps - emits the code for the data portion the code */
/*-----------------------------------------------------------------*/
-void
+void
emitMaps (void)
{
int publicsfr = TARGET_IS_MCS51; /* Ideally, this should be true for all */
/* ports but let's be conservative - EEP */
-
+
inInitMode++;
/* no special considerations for the following
data, idata & bit & xdata */
emitRegularMap (bit, TRUE, TRUE);
emitRegularMap (pdata, TRUE, TRUE);
emitRegularMap (xdata, TRUE, TRUE);
+ emitRegularMap (x_abs, TRUE, TRUE);
if (port->genXINIT) {
emitRegularMap (xidata, TRUE, TRUE);
}
/* flushStatics - flush all currently defined statics out to file */
/* and delete. Temporary function */
/*-----------------------------------------------------------------*/
-void
+void
flushStatics (void)
{
emitStaticSeg (statsg, codeOutBuf);
/*-----------------------------------------------------------------*/
/* createInterruptVect - creates the interrupt vector */
/*-----------------------------------------------------------------*/
-void
+void
createInterruptVect (struct dbuf_s *vBuf)
{
mainf = newSymbol ("main", 0);
char *iComments1 =
{
";--------------------------------------------------------\n"
- "; File Created by SDCC : FreeWare ANSI-C Compiler\n"};
+ "; File Created by SDCC : free open source ANSI-C Compiler\n"};
char *iComments2 =
{
/*-----------------------------------------------------------------*/
/* initialComments - puts in some initial comments */
/*-----------------------------------------------------------------*/
-void
+void
initialComments (FILE * afile)
{
time_t t;
time (&t);
fprintf (afile, "%s", iComments1);
- fprintf (afile, "; Version " SDCC_VERSION_STR " #%s (%s)\n", getBuildNumber(), __DATE__);
- fprintf (afile, "; This file generated %s", asctime (localtime (&t)));
+ fprintf (afile, "; Version " SDCC_VERSION_STR " #%s (%s) (%s)\n",
+ getBuildNumber(), __DATE__, getBuildEnvironment());
+ fprintf (afile, "; This file was generated %s", asctime (localtime (&t)));
fprintf (afile, "%s", iComments2);
}
/*-----------------------------------------------------------------*/
/* printPublics - generates .global for publics */
/*-----------------------------------------------------------------*/
-void
+void
printPublics (FILE * afile)
{
symbol *sym;
/*-----------------------------------------------------------------*/
/* printExterns - generates .global for externs */
/*-----------------------------------------------------------------*/
-void
+void
printExterns (FILE * afile)
{
symbol *sym;
/*-----------------------------------------------------------------*/
/* emitOverlay - will emit code for the overlay stuff */
/*-----------------------------------------------------------------*/
-static void
+static void
emitOverlay (struct dbuf_s * aBuf)
{
set *ovrset;
if (size==0) {
werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE);
- }
+ }
if (options.debug)
dbuf_printf (aBuf, "==.\n");
-
+
/* allocate space */
dbuf_tprintf (aBuf, "!labeldef\n", sym->rname);
dbuf_tprintf (aBuf, "\t!ds\n", (unsigned int) getSize (sym->type) & 0xffff);
}
-
+
}
}
}
-
-/*-----------------------------------------------------------------*/
-/* spacesToUnderscores - replace spaces with underscores */
-/*-----------------------------------------------------------------*/
-static char *
-spacesToUnderscores (char *dest, const char *src, size_t len)
-{
- unsigned int i;
- char *p;
-
- assert(dest != NULL);
- assert(src != NULL);
- assert(len > 0);
-
- --len;
- for (p = dest, i = 0; *src != '\0' && i < len; ++src, ++i) {
- *p++ = isspace((unsigned char)*src) ? '_' : *src;
- }
- *p = '\0';
-
- return dest;
-}
-
-
/*-----------------------------------------------------------------*/
/* glue - the final glue that hold the whole thing together */
/*-----------------------------------------------------------------*/
-void
+void
glue (void)
{
struct dbuf_s vBuf;
struct dbuf_s ovrBuf;
FILE *asmFile;
- char moduleBuf[PATH_MAX];
int mcs51_like;
- dbuf_init(&vBuf, 4096);
- dbuf_init(&ovrBuf, 4096);
+ dbuf_init (&vBuf, 4096);
+ dbuf_init (&ovrBuf, 4096);
- if(port->general.glue_up_main &&
- (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51 || TARGET_IS_DS400))
- {
- mcs51_like=1; /*So it has bits, sfr, sbits, data, idata, etc...*/
- }
- else
- {
- mcs51_like=0;
- }
+ mcs51_like = (port->general.glue_up_main &&
+ (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_XA51 || TARGET_IS_DS400));
/* print the global struct definitions */
if (options.debug)
/* do the overlay segments */
emitOverlay (&ovrBuf);
- outputDebugSymbols();
+ outputDebugSymbols ();
/* now put it all together into the assembler file */
/* create the assembler file name */
if (!(asmFile = fopen (scratchFileName, "w")))
{
werror (E_FILE_OPEN_ERR, scratchFileName);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* initial comments */
initialComments (asmFile);
/* print module name */
- tfprintf (asmFile, "\t!module\n",
- spacesToUnderscores (moduleBuf, moduleName, sizeof moduleBuf));
- if(mcs51_like)
- {
- fprintf (asmFile, "\t.optsdcc -m%s", port->target);
-
- switch(options.model)
+ tfprintf (asmFile, "\t!module\n", moduleName);
+ if (mcs51_like)
{
+ fprintf (asmFile, "\t.optsdcc -m%s", port->target);
+
+ switch(options.model)
+ {
case MODEL_SMALL: fprintf (asmFile, " --model-small"); break;
case MODEL_COMPACT: fprintf (asmFile, " --model-compact"); break;
case MODEL_MEDIUM: fprintf (asmFile, " --model-medium"); break;
case MODEL_FLAT24: fprintf (asmFile, " --model-flat24"); break;
case MODEL_PAGE0: fprintf (asmFile, " --model-page0"); break;
default: break;
+ }
+ /*if(options.stackAuto) fprintf (asmFile, " --stack-auto");*/
+ if(options.useXstack) fprintf (asmFile, " --xstack");
+ /*if(options.intlong_rent) fprintf (asmFile, " --int-long-rent");*/
+ /*if(options.float_rent) fprintf (asmFile, " --float-rent");*/
+ if(options.noRegParams) fprintf (asmFile, " --no-reg-params");
+ if(options.parms_in_bank1) fprintf (asmFile, " --parms-in-bank1");
+ fprintf (asmFile, "\n");
+ }
+ else if (TARGET_Z80_LIKE || TARGET_IS_HC08)
+ {
+ fprintf (asmFile, "\t.optsdcc -m%s\n", port->target);
}
- /*if(options.stackAuto) fprintf (asmFile, " --stack-auto");*/
- if(options.useXstack) fprintf (asmFile, " --xstack");
- /*if(options.intlong_rent) fprintf (asmFile, " --int-long-rent");*/
- /*if(options.float_rent) fprintf (asmFile, " --float-rent");*/
- if(options.noRegParams) fprintf (asmFile, " --no-reg-params");
- if(options.parms_in_bank1) fprintf (asmFile, " --parms-in-bank1");
- fprintf (asmFile, "\n");
- }
- else if(TARGET_IS_Z80 || TARGET_IS_GBZ80 || TARGET_IS_HC08)
- {
- fprintf (asmFile, "\t.optsdcc -m%s\n", port->target);
- }
tfprintf (asmFile, "\t!fileprelude\n");
if (port->assembler.externGlobal)
printExterns (asmFile);
- if(( mcs51_like )
- ||( TARGET_IS_Z80 )) /*.p.t.20030924 need to output SFR table for Z80 as well */
- {
+ if (( mcs51_like )
+ ||( TARGET_IS_Z80 )) /*.p.t.20030924 need to output SFR table for Z80 as well */
+ {
/* copy the sfr segment */
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; special function registers\n");
fprintf (asmFile, "%s", iComments2);
dbuf_write_and_destroy (&sfr->oBuf, asmFile);
- }
-
- if(mcs51_like)
+ }
+
+ if (mcs51_like)
{
/* copy the sbit segment */
fprintf (asmFile, "%s", iComments2);
dbuf_write_and_destroy (&sfrbit->oBuf, asmFile);
/*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");
- }
- if(BitBankUsed)
- {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; overlayable bit register bank\n");
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "\t.area BIT_BANK\t(REL,OVR,DATA)\n");
- fprintf (asmFile, "bits:\n\t.ds 1\n");
- fprintf (asmFile, "\tb0 = bits[0]\n");
- fprintf (asmFile, "\tb1 = bits[1]\n");
- fprintf (asmFile, "\tb2 = bits[2]\n");
- fprintf (asmFile, "\tb3 = bits[3]\n");
- fprintf (asmFile, "\tb4 = bits[4]\n");
- fprintf (asmFile, "\tb5 = bits[5]\n");
- fprintf (asmFile, "\tb6 = bits[6]\n");
- fprintf (asmFile, "\tb7 = bits[7]\n");
- }
+ 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");
+ }
+ if (BitBankUsed)
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; overlayable bit register bank\n");
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "\t.area BIT_BANK\t(REL,OVR,DATA)\n");
+ fprintf (asmFile, "bits:\n\t.ds 1\n");
+ fprintf (asmFile, "\tb0 = bits[0]\n");
+ fprintf (asmFile, "\tb1 = bits[1]\n");
+ fprintf (asmFile, "\tb2 = bits[2]\n");
+ fprintf (asmFile, "\tb3 = bits[3]\n");
+ fprintf (asmFile, "\tb4 = bits[4]\n");
+ fprintf (asmFile, "\tb5 = bits[5]\n");
+ fprintf (asmFile, "\tb6 = bits[6]\n");
+ fprintf (asmFile, "\tb7 = bits[7]\n");
+ }
}
/* copy the data segment */
/* create the overlay segments */
- if (overlay) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; overlayable items in %s ram \n", mcs51_like?"internal":"");
- fprintf (asmFile, "%s", iComments2);
- dbuf_write_and_destroy (&ovrBuf, asmFile);
- }
+ if (overlay)
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; overlayable items in %s ram \n", mcs51_like?"internal":"");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&ovrBuf, asmFile);
+ }
/* create the stack segment MOF */
- if (mainf && IFFUNC_HASBODY(mainf->type))
+ if (mainf && IFFUNC_HASBODY (mainf->type))
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; Stack segment in internal ram \n");
}
/* create the idata segment */
- if ( (idata) && (mcs51_like) ) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; indirectly addressable internal ram data\n");
- fprintf (asmFile, "%s", iComments2);
- dbuf_write_and_destroy (&idata->oBuf, asmFile);
- }
+ if ((idata) && (mcs51_like))
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; indirectly addressable internal ram data\n");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&idata->oBuf, asmFile);
+ }
/* create the absolute idata/data segment */
- if ( (i_abs) && (mcs51_like) ) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; absolute internal ram data\n");
- fprintf (asmFile, "%s", iComments2);
- dbuf_write_and_destroy (&d_abs->oBuf, asmFile);
- dbuf_write_and_destroy (&i_abs->oBuf, asmFile);
- }
+ if ((i_abs) && (mcs51_like))
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; absolute internal ram data\n");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&d_abs->oBuf, asmFile);
+ dbuf_write_and_destroy (&i_abs->oBuf, asmFile);
+ }
/* copy the bit segment */
- if (mcs51_like) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; bit data\n");
- fprintf (asmFile, "%s", iComments2);
- dbuf_write_and_destroy (&bit->oBuf, asmFile);
- }
+ if (mcs51_like)
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; bit data\n");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&bit->oBuf, asmFile);
+ }
/* copy paged external ram data */
if (mcs51_like)
}
/* if external stack then reserve space for it */
- if (mainf && IFFUNC_HASBODY(mainf->type) && options.useXstack)
+ if (mainf && IFFUNC_HASBODY (mainf->type) && options.useXstack)
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; external stack \n");
}
/* copy external ram data */
- if (mcs51_like) {
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; external ram data\n");
- fprintf (asmFile, "%s", iComments2);
- dbuf_write_and_destroy (&xdata->oBuf, asmFile);
- }
+ if (mcs51_like)
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; external ram data\n");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&xdata->oBuf, asmFile);
+ }
+
+ /* create the absolute xdata segment */
+ if (mcs51_like || TARGET_IS_HC08)
+ {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; absolute external ram data\n");
+ fprintf (asmFile, "%s", iComments2);
+ dbuf_write_and_destroy (&x_abs->oBuf, asmFile);
+ }
/* copy external initialized ram data */
fprintf (asmFile, "%s", iComments2);
/* If the port wants to generate any extra areas, let it do so. */
if (port->extraAreas.genExtraAreaDeclaration)
- {
- port->extraAreas.genExtraAreaDeclaration(asmFile,
+ {
+ port->extraAreas.genExtraAreaDeclaration(asmFile,
mainf && IFFUNC_HASBODY(mainf->type));
- }
-
+ }
+
/* copy the interrupt vector table */
- if (mainf && IFFUNC_HASBODY(mainf->type))
+ if (mainf && IFFUNC_HASBODY (mainf->type))
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; interrupt vector \n");
tfprintf (asmFile, "\t!area\n", port->mem.post_static_name);
tfprintf (asmFile, "\t!area\n", port->mem.static_name);
- if (mainf && IFFUNC_HASBODY(mainf->type))
+ if (mainf && IFFUNC_HASBODY (mainf->type))
{
if (port->genInitStartup)
{
- port->genInitStartup(asmFile);
+ port->genInitStartup (asmFile);
}
else
{
+ assert (mcs51_like);
fprintf (asmFile, "__sdcc_gsinit_startup:\n");
/* if external stack is specified then the
higher order byte of the xdatalocation is
fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n"); /* MOF */
}
- fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
+ fprintf (asmFile, "\t%ccall\t__sdcc_external_startup\n", options.acall_ajmp?'a':'l');
fprintf (asmFile, "\tmov\ta,dpl\n");
fprintf (asmFile, "\tjz\t__sdcc_init_data\n");
- fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
+ fprintf (asmFile, "\t%cjmp\t__sdcc_program_startup\n", options.acall_ajmp?'a':'l');
fprintf (asmFile, "__sdcc_init_data:\n");
// if the port can copy the XINIT segment to XISEG
if (port->genXINIT)
{
- port->genXINIT(asmFile);
+ port->genXINIT (asmFile);
}
}
-
}
dbuf_write_and_destroy (&statsg->oBuf, asmFile);
- if (port->general.glue_up_main && mainf && IFFUNC_HASBODY(mainf->type))
+ if (port->general.glue_up_main && mainf && IFFUNC_HASBODY (mainf->type))
{
/* This code is generated in the post-static area.
* This area is guaranteed to follow the static area
* by the ugly shucking and jiving about 20 lines ago.
*/
tfprintf (asmFile, "\t!area\n", port->mem.post_static_name);
- fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
+ fprintf (asmFile, "\t%cjmp\t__sdcc_program_startup\n", options.acall_ajmp?'a':'l');
}
fprintf (asmFile,
tfprintf (asmFile, "\t!areahome\n", HOME_NAME);
dbuf_write_and_destroy (&home->oBuf, asmFile);
- if (mainf && IFFUNC_HASBODY(mainf->type))
+ if (mainf && IFFUNC_HASBODY (mainf->type))
{
/* entry point @ start of HOME */
fprintf (asmFile, "__sdcc_program_startup:\n");
/* put in jump or call to main */
if (options.mainreturn)
{
- fprintf (asmFile, "\tljmp\t_main\n"); /* needed? */
+ fprintf (asmFile, "\t%cjmp\t_main\n", options.acall_ajmp?'a':'l'); /* needed? */
fprintf (asmFile, ";\treturn from main will return to caller\n");
}
else
{
- fprintf (asmFile, "\tlcall\t_main\n");
+ fprintf (asmFile, "\t%ccall\t_main\n", options.acall_ajmp?'a':'l');
fprintf (asmFile, ";\treturn from main will lock up\n");
fprintf (asmFile, "\tsjmp .\n");
}
tfprintf (asmFile, "\t!areacode\n", options.code_seg);
dbuf_write_and_destroy (&code->oBuf, asmFile);
- if (port->genAssemblerEnd) {
- port->genAssemblerEnd(asmFile);
- }
+ if (port->genAssemblerEnd)
+ {
+ port->genAssemblerEnd (asmFile);
+ }
fclose (asmFile);
}