/* */
/* */
/* */
-/* (C) 1998-2003 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 */
Error ("Command is only valid in 65816 mode");
} else {
/* Immidiate mode has two extension bytes */
- ExtBytes [AMI_IMM_ACCU] = 2;
+ ExtBytes [AM65I_IMM_ACCU] = 2;
}
}
Error ("Command is only valid in 65816 mode");
} else {
/* Immidiate mode has one extension byte */
- ExtBytes [AMI_IMM_ACCU] = 1;
+ ExtBytes [AM65I_IMM_ACCU] = 1;
}
}
"ERROR"
};
- int Action;
-
+ 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");
- } else {
- AddAssertion (Expr, Action, GetStringId (SVal));
+ /* We can have an optional message. If no message is present, use
+ * "Assertion failed".
+ */
+ if (Tok == TOK_COMMA) {
+
+ /* Skip the comma */
+ NextTok ();
+
+ /* 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 {
+
+ /* Use "Assertion failed" */
+ Msg = GetStringId ("Assertion failed");
+
}
+
+ /* Remember the assertion */
+ AddAssertion (Expr, Action, Msg);
}
} else {
EmitByte (Expression ());
}
- if (Tok != TOK_COMMA) {
+ if (Tok != TOK_COMMA) {
break;
} else {
NextTok ();
/* Read the index as numerical value */
Index = ConstExpression ();
- if (Index < 1 || Index > 255) {
+ if (Index < 0 || Index > 255) {
/* Value out of range */
ErrorSkip ("Range error");
return;
/* Read the character code */
Code = ConstExpression ();
- if (Code < 1 || Code > 255) {
- /* Value out of range */
+ if (Code < 0 || Code > 255) {
+ /* Value out of range */
ErrorSkip ("Range error");
- return;
+ return;
}
/* Set the character translation */
static const char* Keys[] = {
"CONSTRUCTOR",
"DESTRUCTOR",
+ "INTERRUPTOR",
};
char Name [sizeof (SVal)];
long Type;
Error ("Command is only valid in 65816 mode");
} else {
/* Immidiate mode has two extension bytes */
- ExtBytes [AMI_IMM_INDEX] = 2;
+ ExtBytes [AM65I_IMM_INDEX] = 2;
}
}
Error ("Command is only valid in 65816 mode");
} else {
/* Immidiate mode has one extension byte */
- ExtBytes [AMI_IMM_INDEX] = 1;
+ ExtBytes [AM65I_IMM_INDEX] = 1;
}
}
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 DoInterruptor (void)
+/* Export a symbol as interruptor */
+{
+ char Name [sizeof (SVal)];
+
+ /* Symbol name follows */
+ if (Tok != TOK_IDENT) {
+ ErrorSkip ("Identifier expected");
+ return;
+ }
+ strcpy (Name, SVal);
+ NextTok ();
+
+ /* Parse the remainder of the line and export the symbol */
+ ConDes (Name, CD_TYPE_INT);
+}
+
+
+
static void DoInvalid (void)
/* Handle a token that is invalid here, since it should have been handled on
* a much lower level of the expression hierarchy. Getting this sort of token
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 ();
}
if (Tok != TOK_STRCON) {
ErrorSkip ("String constant expected");
} else {
- /* Try to find the CPU, then skip the identifier */
+ /* Try to find the CPU */
cpu_t CPU = FindCPU (SVal);
- NextTok ();
/* Switch to the new CPU */
SetCPU (CPU);
+
+ /* Skip the identifier. If the CPU switch was successful, the scanner
+ * will treat the input now correctly for the new CPU.
+ */
+ NextTok ();
}
}
{ ccNone, DoUnexpected }, /* .HIWORD */
{ ccNone, DoI16 },
{ ccNone, DoI8 },
+ { ccNone, DoUnexpected }, /* .IDENT */
{ ccKeepToken, DoConditionals }, /* .IF */
{ ccKeepToken, DoConditionals }, /* .IFBLANK */
{ ccKeepToken, DoConditionals }, /* .IFCONST */
{ ccNone, DoImportZP },
{ ccNone, DoIncBin },
{ ccNone, DoInclude },
+ { ccNone, DoInterruptor },
{ ccNone, DoInvalid }, /* .LEFT */
{ ccNone, DoLineCont },
{ ccNone, DoList },
{ 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 */
/* Safety check */
if (PSEUDO_COUNT != (TOK_LASTPSEUDO - TOK_FIRSTPSEUDO + 1)) {
Internal ("Pseudo mismatch: PSEUDO_COUNT = %u, actual count = %u\n",
- PSEUDO_COUNT, TOK_LASTPSEUDO - TOK_FIRSTPSEUDO + 1);
+ (unsigned) PSEUDO_COUNT, TOK_LASTPSEUDO - TOK_FIRSTPSEUDO + 1);
}
CHECK (Index < PSEUDO_COUNT);