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->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 = ulFromVal(val);
/*-----------------------------------------------------------------*/
/* printIvalStruct - generates initial value for structures */
/*-----------------------------------------------------------------*/
-void
+void
printIvalStruct (symbol * sym, sym_link * type,
initList * ilist, struct dbuf_s * oBuf)
{
/*-----------------------------------------------------------------*/
/* 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;
/*-----------------------------------------------------------------*/
/* printIvalCharPtr - generates initial values for character pointers */
/*-----------------------------------------------------------------*/
-int
+int
printIvalCharPtr (symbol * sym, sym_link * type, value * val, struct dbuf_s * oBuf)
{
int size = 0;
}
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;
/*-----------------------------------------------------------------*/
/* 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++;
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,
+ /* 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 */
/* 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);
/*-----------------------------------------------------------------*/
/* initialComments - puts in some initial comments */
/*-----------------------------------------------------------------*/
-void
+void
initialComments (FILE * afile)
{
time_t t;
/*-----------------------------------------------------------------*/
/* 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);
}
-
+
}
}
}
/*-----------------------------------------------------------------*/
/* glue - the final glue that hold the whole thing together */
/*-----------------------------------------------------------------*/
-void
+void
glue (void)
{
struct dbuf_s vBuf;
fprintf (asmFile, "%s", iComments2);
dbuf_write_and_destroy (&sfr->oBuf, asmFile);
}
-
+
if(mcs51_like)
{
/* copy the sbit segment */
/* 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))
{