+/*****************************************************************************/
/* */
/* main.c */
/* */
AbEnd ("Cannot use `module' as a target for the assembler");
break;
+ case TGT_ATARI2600:
+ NewSymbol ("__ATARI2600__", 1);
+ break;
+
+ case TGT_ATARI5200:
+ NewSymbol ("__ATARI5200__", 1);
+ break;
+
case TGT_ATARI:
NewSymbol ("__ATARI__", 1);
break;
CBMSystem ("__C64__");
break;
+ case TGT_C65:
+ CBMSystem ("__C65__");
+ break;
+
case TGT_VIC20:
CBMSystem ("__VIC20__");
break;
break;
case TGT_PLUS4:
- CBMSystem ("__PLUS4__");
+ CBMSystem ("__C16__");
+ NewSymbol ("__PLUS4__", 1);
break;
case TGT_CBM510:
CBMSystem ("__PET__");
break;
- case TGT_BBC:
- NewSymbol ("__BBC__", 1);
- break;
-
case TGT_APPLE2:
NewSymbol ("__APPLE2__", 1);
break;
NewSymbol ("__APPLE2ENH__", 1);
break;
+ case TGT_GAMATE:
+ NewSymbol ("__GAMATE__", 1);
+ break;
+
case TGT_GEOS_CBM:
/* Do not handle as a CBM system */
NewSymbol ("__GEOS__", 1);
NewSymbol ("__GEOS_CBM__", 1);
break;
+ case TGT_ATMOS:
+ NewSymbol ("__ATMOS__", 1);
+ break;
+
+ case TGT_BBC:
+ NewSymbol ("__BBC__", 1);
+ break;
+
+ case TGT_CREATIVISION:
+ NewSymbol ("__CREATIVISION__", 1);
+ break;
+
case TGT_GEOS_APPLE:
NewSymbol ("__GEOS__", 1);
NewSymbol ("__GEOS_APPLE__", 1);
NewSymbol ("__LUNIX__", 1);
break;
- case TGT_ATMOS:
- NewSymbol ("__ATMOS__", 1);
+ case TGT_LYNX:
+ NewSymbol ("__LYNX__", 1);
break;
case TGT_NES:
NewSymbol ("__NES__", 1);
break;
- case TGT_SUPERVISION:
- NewSymbol ("__SUPERVISION__", 1);
- break;
-
- case TGT_LYNX:
- NewSymbol ("__LYNX__", 1);
- break;
-
case TGT_SIM6502:
NewSymbol ("__SIM6502__", 1);
break;
NewSymbol ("__SIM65C02__", 1);
break;
+ case TGT_OSIC1P:
+ NewSymbol ("__OSIC1P__", 1);
+ break;
+
+ case TGT_PCENGINE:
+ NewSymbol ("__PCE__", 1);
+ break;
+
+ case TGT_SUPERVISION:
+ NewSymbol ("__SUPERVISION__", 1);
+ break;
+
default:
AbEnd ("Invalid target name: `%s'", Sys);
/* Create a listing file */
{
/* Since the meaning of -l and --listing has changed, print an error if
- * the filename is empty or begins with the option char.
- */
+ ** the filename is empty or begins with the option char.
+ */
if (Arg == 0 || *Arg == '\0' || *Arg == '-') {
Fatal ("The meaning of `%s' has changed. It does now "
"expect a file name as argument.", Opt);
const char* Arg attribute ((unused)))
/* Print the assembler version */
{
- fprintf (stderr, "ca65 V%s\n", GetVersionAsString ());
+ fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
+ exit(EXIT_SUCCESS);
}
int Instr = -1;
/* Initialize the new listing line if we are actually reading from file
- * and not from internally pushed input.
- */
+ ** and not from internally pushed input.
+ */
if (!HavePushedInput ()) {
InitListingLine ();
}
}
/* If the first token on the line is an identifier, check for a macro or
- * an instruction.
- */
+ ** an instruction.
+ */
if (CurTok.Tok == TOK_IDENT) {
- if (!UbiquitousIdents) {
- /* Macros and symbols cannot use instruction names */
+ if (UbiquitousIdents) {
+ /* Macros CAN be instructions, so check for them first */
+ Mac = FindMacro (&CurTok.SVal);
+ if (Mac == 0) {
+ Instr = FindInstruction (&CurTok.SVal);
+ }
+ } else {
+ /* Macros and symbols may NOT use the names of instructions */
Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
Mac = FindMacro (&CurTok.SVal);
}
- } else {
- /* Macros and symbols may use the names of instructions */
- Mac = FindMacro (&CurTok.SVal);
}
}
/* Handle an identifier. This may be a cheap local symbol, or a fully
- * scoped identifier which may start with a namespace token (for global
- * namespace)
- */
+ ** scoped identifier which may start with a namespace token (for global
+ ** namespace)
+ */
if (CurTok.Tok == TOK_LOCAL_IDENT ||
CurTok.Tok == TOK_NAMESPACE ||
(CurTok.Tok == TOK_IDENT && Instr < 0 && Mac == 0)) {
Sym = ParseAnySymName (SYM_ALLOC_NEW);
/* If a colon follows, this is a label definition. If there
- * is no colon, it's an assignment.
- */
+ ** is no colon, it's an assignment.
+ */
if (CurTok.Tok == TOK_EQ || CurTok.Tok == TOK_ASSIGN) {
/* Determine the symbol flags from the assignment token */
Expr = GenLiteralExpr (ConstExpression ());
/* Define the symbol with the constant expression following
- * the '='
- */
+ ** the '='
+ */
SymDef (Sym, Expr, ADDR_SIZE_DEFAULT, SF_VAR);
/* Don't allow anything after a symbol definition */
} else {
/* A label. Remember the current segment, so we can later
- * determine the size of the data stored under the label.
- */
+ ** determine the size of the data stored under the label.
+ */
Seg = ActiveSeg;
PC = GetPC ();
SymDef (Sym, GenCurrentPC (), ADDR_SIZE_DEFAULT, SF_LABEL);
/* Skip the colon. If NoColonLabels is enabled, allow labels
- * without a colon if there is no whitespace before the
- * identifier.
- */
+ ** without a colon if there is no whitespace before the
+ ** identifier.
+ */
if (CurTok.Tok != TOK_COLON) {
if (HadWS || !NoColonLabels) {
Error ("`:' expected");
}
/* If we come here, a new identifier may be waiting, which may
- * be a macro or instruction.
- */
+ ** be a macro or instruction.
+ */
if (CurTok.Tok == TOK_IDENT) {
- if (!UbiquitousIdents) {
- /* Macros and symbols cannot use instruction names */
+ if (UbiquitousIdents) {
+ /* Macros CAN be instructions, so check for them first */
+ Mac = FindMacro (&CurTok.SVal);
+ if (Mac == 0) {
+ Instr = FindInstruction (&CurTok.SVal);
+ }
+ } else {
+ /* Macros and symbols may NOT use the names of instructions */
Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
Mac = FindMacro (&CurTok.SVal);
}
- } else {
- /* Macros and symbols may use the names of instructions */
- Mac = FindMacro (&CurTok.SVal);
}
}
}
} else if (Mac != 0) {
/* A macro expansion */
MacExpandStart (Mac);
- } else if (Instr >= 0 ||
- (UbiquitousIdents && ((Instr = FindInstruction (&CurTok.SVal)) >= 0))) {
+ } else if (Instr >= 0) {
/* A mnemonic - assemble one instruction */
HandleInstruction (Instr);
} else if (PCAssignment && (CurTok.Tok == TOK_STAR || CurTok.Tok == TOK_PC)) {
}
/* If we have defined a label, remember its size. Sym is also set by
- * a symbol assignment, but in this case Done is false, so we don't
- * come here.
- */
+ ** a symbol assignment, but in this case Done is false, so we don't
+ ** come here.
+ */
if (Sym) {
unsigned long Size;
if (Seg == ActiveSeg) {
SegInit ();
/* Enter the base lexical level. We must do that here, since we may
- * define symbols using -D.
- */
+ ** define symbols using -D.
+ */
SymEnterLevel (&GlobalNameSpace, SCOPE_FILE, ADDR_SIZE_DEFAULT, 0);
/* Initialize the line infos. Must be done here, since we need line infos
- * for symbol definitions.
- */
+ ** for symbol definitions.
+ */
InitLineInfo ();
/* Check the parameters */
DoneLineInfo ();
/* If we didn't have any errors, create the object, listing and
- * dependency files
- */
+ ** dependency files
+ */
if (ErrorCount == 0) {
CreateObjFile ();
if (SB_GetLen (&ListingName) > 0) {
/* Return an apropriate exit code */
return (ErrorCount == 0)? EXIT_SUCCESS : EXIT_FAILURE;
}
-
-
-