/* */
/* */
/* */
-/* (C) 2000-2003 Ullrich von Bassewitz */
+/* (C) 2000-2004 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
"leading_dot_in_identifiers",
"pc_assignment",
"missing_char_term",
+ "ubiquitous_idents",
};
case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= 1; break;
case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break;
case FEAT_MISSING_CHAR_TERM: MissingCharTerm = 1; break;
+ case FEAT_UBIQUITOUS_IDENTS: UbiquitousIdents = 1; break;
default: /* Keep gcc silent */ break;
}
FEAT_LEADING_DOT_IN_IDENTIFIERS,
FEAT_PC_ASSIGNMENT,
FEAT_MISSING_CHAR_TERM,
+ FEAT_UBIQUITOUS_IDENTS,
/* Special value: Number of features available */
FEAT_COUNT
unsigned char LeadingDotInIdents = 0; /* Allow '.' to start an identifier */
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */
unsigned char MissingCharTerm = 0; /* Allow lda #'a (no closing term) */
+unsigned char UbiquitousIdents = 0; /* Allow ubiquitous identifiers */
/* Misc stuff */
const char Copyright[] = "(C) Copyright 1998-2004 Ullrich von Bassewitz";
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
+/* (C) 1998-2004 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
extern unsigned char LeadingDotInIdents; /* Allow '.' to start an identifier */
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
extern unsigned char MissingCharTerm; /* Allow lda #'a (no closing term) */
+extern unsigned char UbiquitousIdents; /* Allow ubiquitous identifiers */
/* Misc stuff */
extern const char Copyright[]; /* Copyright string */
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
+/* (C) 1998-2004 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
#include "condasm.h"
#include "error.h"
#include "global.h"
+#include "instr.h"
#include "istack.h"
#include "nexttok.h"
#include "pseudo.h"
Error ("Identifier expected");
MacSkipDef (Style);
return;
+ } else if (!UbiquitousIdents && FindInstruction (SVal) >= 0) {
+ /* The identifier is a name of a 6502 instruction, which is not
+ * allowed if not explicitly enabled.
+ */
+ Error ("Cannot use an instruction as macro name");
+ MacSkipDef (Style);
+ return;
}
/* Did we already define that macro? */
while (1) {
if (strcmp (List->Id, SVal) == 0) {
Error ("Duplicate symbol `%s'", SVal);
- }
+ }
if (List->Next == 0) {
break;
} else {
/* Check for maximum parameter count */
if (E->ParamCount >= M->ParamCount) {
Error ("Too many macro parameters");
- SkipUntilSep ();
+ SkipUntilSep ();
break;
}
static void OneLine (void)
/* Assemble one line */
{
- Segment* Seg = 0;
- unsigned long PC = 0;
- SymEntry* Sym = 0;
- int Done = 0;
+ Segment* Seg = 0;
+ unsigned long PC = 0;
+ SymEntry* Sym = 0;
+ int Done = 0;
+ int Macro = 0;
+ int Instr = -1;
/* Initialize the new listing line if we are actually reading from file
* and not from internally pushed input.
*/
if (!HavePushedInput ()) {
- InitListingLine ();
+ InitListingLine ();
}
if (Tok == TOK_COLON) {
- /* An unnamed label */
- ULabDef ();
- NextTok ();
+ /* An unnamed label */
+ ULabDef ();
+ NextTok ();
}
- /* Assemble the line */
- if (Tok == TOK_LOCAL_IDENT || (Tok == TOK_IDENT && !IsMacro (SVal))) {
+ /* If the first token on the line is an identifier, check for a macro or
+ * an instruction.
+ */
+ if (Tok == TOK_IDENT) {
+ if (!UbiquitousIdents) {
+ /* Macros and symbols cannot use instruction names */
+ Instr = FindInstruction (SVal);
+ if (Instr < 0) {
+ Macro = IsMacro (SVal);
+ }
+ } else {
+ /* Macros and symbols may use the names of instructions */
+ Macro = IsMacro (SVal);
+ }
+ }
+
+ /* Handle an identifier */
+ if (Tok == TOK_LOCAL_IDENT || (Tok == TOK_IDENT && Instr < 0 && !Macro)) {
/* Did we have whitespace before the ident? */
int HadWS = WS;
if (Tok >= TOK_FIRSTPSEUDO && Tok <= TOK_LASTPSEUDO) {
/* A control command */
HandlePseudo ();
- } else if (Tok == TOK_MNEMO) {
- /* A mnemonic - assemble one instruction */
- HandleInstruction (IVal);
- } else if (Tok == TOK_IDENT && IsMacro (SVal)) {
+ } else if (Macro) {
/* A macro expansion */
MacExpandStart ();
+ } else if (Instr >= 0 ||
+ (UbiquitousIdents && ((Instr = FindInstruction (SVal)) >= 0))) {
+ /* A mnemonic - assemble one instruction */
+ HandleInstruction (Instr);
} else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
NextTok ();
if (Tok != TOK_EQ) {
/* Return the length of the string */
return I;
-}
+}
}
}
- /* Search for an opcode */
- IVal = FindInstruction (SVal);
- if (IVal >= 0) {
- /* This is a mnemonic */
- Tok = TOK_MNEMO;
- } else if (IsDefine (SVal)) {
- /* This is a define style macro - expand it */
+ /* Check for define style macro */
+ if (IsDefine (SVal)) {
+ /* Macro - expand it */
MacExpandStart ();
goto Restart;
} else {
int TokHasIVal (enum Token Tok)
/* Return true if the given token has an attached IVal */
{
- return (Tok == TOK_INTCON || Tok == TOK_CHARCON || Tok == TOK_MNEMO);
+ return (Tok == TOK_INTCON || Tok == TOK_CHARCON);
}
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
+/* (C) 1998-2004 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
TOK_SEP, /* Separator (usually newline) */
TOK_IDENT, /* An identifier */
TOK_LOCAL_IDENT, /* A cheap local identifier */
- TOK_MNEMO, /* A mnemonic */
TOK_INTCON, /* Integer constant */
TOK_CHARCON, /* Character constant */