/* */
/* */
/* */
-/* (C) 1998-2004 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2007, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
+static void ExportWithAssign (SymEntry* Sym, unsigned char AddrSize, unsigned Flags)
+/* Allow to assign the value of an export in an .export statement */
+{
+ /* The name and optional address size spec may be followed by an assignment
+ * or equal token.
+ */
+ if (Tok == TOK_ASSIGN || Tok == TOK_EQ) {
+
+ /* Assignment means the symbol is a label */
+ if (Tok == TOK_ASSIGN) {
+ Flags |= SF_LABEL;
+ }
+
+ /* Skip the assignment token */
+ NextTok ();
+
+ /* Define the symbol with the expression following the '=' */
+ SymDef (Sym, Expression(), ADDR_SIZE_DEFAULT, Flags);
+
+ }
+
+ /* Now export the symbol */
+ SymExport (Sym, AddrSize, Flags);
+}
+
+
+
static void ExportImport (void (*Func) (SymEntry*, unsigned char, unsigned),
unsigned char DefAddrSize, unsigned Flags)
/* Export or import symbols */
"ERROR"
};
- int Action;
- long Val;
+ int Action;
+ unsigned Msg;
/* First we have the expression that has to evaluated */
ExprNode* Expr = Expression ();
Error ("Illegal assert action specifier");
}
NextTok ();
- ConsumeComma ();
-
- /* Read the message */
- if (Tok != TOK_STRCON) {
- ErrorSkip ("String constant expected");
- return;
- }
- /* If we can evaluate the assertion now, there's no need to pass it to the
- * linker.
+ /* We can have an optional message. If no message is present, use
+ * "Assertion failed".
*/
- if (IsConstExpr (Expr, &Val)) {
- /* We can evaluate the expression, so handle it in the assembler */
- switch (Action) {
-
- case ASSERT_ACT_WARN:
- Warning (0, "%s", SVal);
- break;
+ if (Tok == TOK_COMMA) {
- case ASSERT_ACT_ERROR:
- Error ("%s", SVal);
- break;
+ /* Skip the comma */
+ NextTok ();
- default:
- Internal ("Illegal assert action specifier");
- break;
+ /* Read the message */
+ if (Tok != TOK_STRCON) {
+ ErrorSkip ("String constant expected");
+ return;
}
+
+ /* Translate the message into a string id. We can then skip the input
+ * string.
+ */
+ Msg = GetStringId (SVal);
+ NextTok ();
+
} else {
- /* Cannot evaluate, add it to the object file */
- AddAssertion (Expr, Action, GetStringId (SVal));
+
+ /* Use "Assertion failed" */
+ Msg = GetStringId ("Assertion failed");
+
}
- /* Skip the message */
- NextTok ();
+ /* Remember the assertion */
+ AddAssertion (Expr, Action, Msg);
}
static void DoExport (void)
/* Export a symbol */
{
- ExportImport (SymExport, ADDR_SIZE_DEFAULT, SF_NONE);
+ ExportImport (ExportWithAssign, ADDR_SIZE_DEFAULT, SF_NONE);
}
static void DoExportZP (void)
/* Export a zeropage symbol */
{
- ExportImport (SymExport, ADDR_SIZE_ZP, SF_NONE);
+ ExportImport (ExportWithAssign, ADDR_SIZE_ZP, SF_NONE);
}
static void DoInclude (void)
/* Include another file */
{
- char Name [MAX_STR_LEN+1];
-
/* Name must follow */
if (Tok != TOK_STRCON) {
ErrorSkip ("String constant expected");
} else {
- strcpy (Name, SVal);
- NextTok ();
- NewInputFile (Name);
+ NewInputFile (SVal);
}
}
static void DoMacPack (void)
/* Insert a macro package */
{
- /* Macro package names */
- static const char* Keys [] = {
- "GENERIC",
- "LONGBRANCH",
- "CBM",
- "CPU"
- };
-
int Package;
/* We expect an identifier */
return;
}
- /* Map the keyword to a number */
- Package = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
+ /* Search for the macro package name */
+ Package = MacPackFind (SVal);
if (Package < 0) {
/* Not found */
ErrorSkip ("Invalid macro package");
return;
}
- /* Skip the package name */
- NextTok ();
-
/* Insert the package */
- InsertMacPack (Package);
+ MacPackInsert (Package);
}
Error ("Range error");
return;
}
- SetAbsPC (PC);
+ EnterAbsoluteMode (PC);
}
static void DoReloc (void)
/* Enter relocatable mode */
{
- RelocMode = 1;
+ EnterRelocMode ();
}
{ ccNone, DoUnexpected }, /* .HIWORD */
{ ccNone, DoI16 },
{ ccNone, DoI8 },
+ { ccNone, DoUnexpected }, /* .IDENT */
{ ccKeepToken, DoConditionals }, /* .IF */
{ ccKeepToken, DoConditionals }, /* .IFBLANK */
{ ccKeepToken, DoConditionals }, /* .IFCONST */
{ ccNone, DoROData },
{ ccNone, DoScope },
{ ccNone, DoSegment },
+ { ccNone, DoUnexpected }, /* .SET */
{ ccNone, DoSetCPU },
{ ccNone, DoUnexpected }, /* .SIZEOF */
{ ccNone, DoSmart },
+ { ccNone, DoUnexpected }, /* .SPRINTF */
{ ccNone, DoUnexpected }, /* .STRAT */
{ ccNone, DoUnexpected }, /* .STRING */
{ ccNone, DoUnexpected }, /* .STRLEN */