an equate for this no need to allocate space */
if (SPEC_ABSA (sym->etype))
{
+ char *equ="=";
if (options.debug) {
fprintf (map->oFile, " == 0x%04x\n", SPEC_ADDR (sym->etype));
}
- fprintf (map->oFile, "%s\t=\t0x%04x\n",
- sym->rname,
+ if (TARGET_IS_XA51) {
+ if (map==sfr) {
+ equ="sfr";
+ } else if (map==bit || map==sfrbit) {
+ equ="bit";
+ }
+ }
+ fprintf (map->oFile, "%s\t%s\t0x%04x\n",
+ sym->rname, equ,
SPEC_ADDR (sym->etype));
}
else {
/* initPointer - pointer initialization code massaging */
/*-----------------------------------------------------------------*/
value *
-initPointer (initList * ilist)
+initPointer (initList * ilist, sym_link *toType)
{
value *val;
ast *expr = list2expr (ilist);
if ((val = constExprValue (expr, FALSE)))
return val;
+ /* ( ptr + constant ) */
+ if (IS_AST_OP (expr) &&
+ (expr->opval.op == '+' || expr->opval.op == '-') &&
+ IS_AST_SYM_VALUE (expr->left) &&
+ (IS_ARRAY(expr->left->ftype) || IS_PTR(expr->left->ftype)) &&
+ compareType(toType, expr->left->ftype) &&
+ IS_AST_LIT_VALUE (expr->right)) {
+ return valForCastAggr (expr->left, expr->left->ftype,
+ 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=='&') {
+ if (compareType(toType, expr->left->ftype)!=1) {
+ werror (W_INIT_WRONG);
+ printFromToType(expr->left->ftype, toType);
+ }
+ // skip the cast ???
+ expr=expr->right;
+ }
+
/* no then we have to do these cludgy checks */
/* pointers can be initialized with address of
a variable or address of an array element */
expr->right, expr->opval.op);
}
-
/* case 4. (char *)(array type) */
if (IS_CAST_OP(expr) && IS_AST_SYM_VALUE (expr->right) &&
IS_ARRAY(expr->right->ftype)) {
return val;
}
wrong:
- werror (W_INIT_WRONG);
+ werror (E_INCOMPAT_PTYPES);
return NULL;
}
{
case IPOINTER:
case POINTER:
- return 0;
+ return GPTYPE_NEAR;
case GPOINTER:
- /* hack - if we get a generic pointer, we just assume
- * it's an FPOINTER (i.e. in XDATA space).
- */
- werror (E_CANNOT_USE_GENERIC_POINTER, iname, oname);
+ werror (E_CANNOT_USE_GENERIC_POINTER,
+ iname ? iname : "<null>",
+ oname ? oname : "<null>");
exit (1);
- // fall through
case FPOINTER:
- return 1;
+ return GPTYPE_FAR;
case CPOINTER:
- return 2;
+ return GPTYPE_CODE;
case PPOINTER:
- return 3;
+ return GPTYPE_XSTACK;
default:
fprintf (stderr, "*** internal error: unknown pointer type %d in GPByte.\n",
p_type);
/* by a string */
if (IS_CHAR (type->next)) {
if (!IS_LITERAL(list2val(ilist)->etype)) {
- werror (W_INIT_WRONG);
+ werror (E_CONST_EXPECTED);
return;
}
if (printIvalChar (type,
val = list2val (ilist);
+ if (!val) {
+ // an error has been thrown allready
+ val=constVal("0");
+ }
+
if (IS_LITERAL(val->etype)) {
if (compareType(type,val->etype)==0) {
werror (E_INCOMPAT_TYPES);
return;
}
- if (!(val = initPointer (ilist)))
+ if (!(val = initPointer (ilist, type)))
return;
/* if character pointer */
return;
/* check the type */
- if (compareType (type, val->type) == 0)
+ if (compareType (type, val->type) == 0) {
werror (W_INIT_WRONG);
+ printFromToType (val->type, type);
+ }
/* if val is literal */
if (IS_LITERAL (val->etype))
else
tfprintf (oFile, "\t.byte %s,%s\n", aopLiteral (val, 0), aopLiteral (val, 1));
break;
- case 3:
- fprintf (oFile, "\t.byte %s,%s,#0x02\n",
- aopLiteral (val, 0), aopLiteral (val, 1));
+ case 3: // how about '390??
+ fprintf (oFile, "\t.byte %s,%s,#0x%d\n",
+ aopLiteral (val, 0), aopLiteral (val, 1), GPTYPE_CODE);
}
return;
}
if (!ilist)
return;
+ /* update line number for error msgs */
+ lineno=sym->lineDef;
+
/* if structure then */
if (IS_STRUCT (type))
{
/* create the overlay segments */
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; overlayable items in internal ram \n");
- fprintf (asmFile, "%s", iComments2);
- copyFile (asmFile, ovrFile);
+ if (overlay) {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; overlayable items in internal ram \n");
+ fprintf (asmFile, "%s", iComments2);
+ copyFile (asmFile, ovrFile);
+ }
/* create the stack segment MOF */
if (mainf && IFFUNC_HASBODY(mainf->type))
}
/* create the idata segment */
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; indirectly addressable internal ram data\n");
- fprintf (asmFile, "%s", iComments2);
- copyFile (asmFile, idata->oFile);
+ if (idata) {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; indirectly addressable internal ram data\n");
+ fprintf (asmFile, "%s", iComments2);
+ copyFile (asmFile, idata->oFile);
+ }
/* copy the bit segment */
fprintf (asmFile, "%s", iComments2);