/* */
/* */
/* */
-/* (C) 1998-2010, Ullrich von Bassewitz */
+/* (C) 1998-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
" -g\t\t\t\tAdd debug info to object file\n"
" -h\t\t\t\tHelp (this text)\n"
" -i\t\t\t\tIgnore case of symbols\n"
- " -l\t\t\t\tCreate a listing if assembly was ok\n"
+ " -l name\t\t\tCreate a listing file if assembly was ok\n"
" -mm model\t\t\tSet the memory model\n"
" -o name\t\t\tName the output file\n"
" -s\t\t\t\tEnable smart mode\n"
" --help\t\t\tHelp (this text)\n"
" --ignore-case\t\t\tIgnore case of symbols\n"
" --include-dir dir\t\tSet an include directory search path\n"
- " --listing\t\t\tCreate a listing if assembly was ok\n"
+ " --listing name\t\tCreate a listing file if assembly was ok\n"
" --list-bytes n\t\tMaximum number of bytes per listing line\n"
" --macpack-dir dir\t\tSet a macro package directory\n"
" --memory-model model\t\tSet the memory model\n"
static void OptBinIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
/* Add an include search path for binaries */
{
- AddIncludePath (Arg, INC_BIN);
+ AddSearchPath (BinSearchPath, Arg);
}
static void OptCreateFullDep (const char* Opt attribute ((unused)),
- const char* Arg)
+ const char* Arg)
/* Handle the --create-full-dep option */
{
FileNameOption (Opt, Arg, &FullDepName);
static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
/* Add an include search path */
{
- AddIncludePath (Arg, INC_STD);
+ AddSearchPath (IncSearchPath, Arg);
}
-static void OptListing (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+static void OptListing (const char* Opt, const char* Arg)
/* Create a listing file */
-{
- Listing = 1;
+{
+ /* Since the meaning of -l and --listing has changed, print an error if
+ * 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);
+ }
+
+ /* Get the file name */
+ FileNameOption (Opt, Arg, &ListingName);
}
InitListingLine ();
}
- if (Tok == TOK_COLON) {
+ if (CurTok.Tok == TOK_COLON) {
/* An unnamed label */
ULabDef ();
NextTok ();
/* If the first token on the line is an identifier, check for a macro or
* an instruction.
*/
- if (Tok == TOK_IDENT) {
+ if (CurTok.Tok == TOK_IDENT) {
if (!UbiquitousIdents) {
/* Macros and symbols cannot use instruction names */
- Instr = FindInstruction (&SVal);
+ Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
- Macro = IsMacro (&SVal);
+ Macro = IsMacro (&CurTok.SVal);
}
} else {
/* Macros and symbols may use the names of instructions */
- Macro = IsMacro (&SVal);
+ Macro = IsMacro (&CurTok.SVal);
}
}
* scoped identifier which may start with a namespace token (for global
* namespace)
*/
- if (Tok == TOK_LOCAL_IDENT ||
- Tok == TOK_NAMESPACE ||
- (Tok == TOK_IDENT && Instr < 0 && !Macro)) {
+ if (CurTok.Tok == TOK_LOCAL_IDENT ||
+ CurTok.Tok == TOK_NAMESPACE ||
+ (CurTok.Tok == TOK_IDENT && Instr < 0 && !Macro)) {
/* Did we have whitespace before the ident? */
- int HadWS = WS;
+ int HadWS = CurTok.WS;
/* Generate the symbol table entry, then skip the name */
- if (Tok == TOK_LOCAL_IDENT) {
- Sym = SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW);
- NextTok ();
- } else {
- Sym = ParseScopedSymName (SYM_ALLOC_NEW);
- }
+ Sym = ParseAnySymName (SYM_ALLOC_NEW);
/* If a colon follows, this is a label definition. If there
* is no colon, it's an assignment.
*/
- if (Tok == TOK_EQ || Tok == TOK_ASSIGN) {
+ if (CurTok.Tok == TOK_EQ || CurTok.Tok == TOK_ASSIGN) {
/* Determine the symbol flags from the assignment token */
- unsigned Flags = (Tok == TOK_ASSIGN)? SF_LABEL : SF_NONE;
+ unsigned Flags = (CurTok.Tok == TOK_ASSIGN)? SF_LABEL : SF_NONE;
/* Skip the '=' */
NextTok ();
ConsumeSep ();
return;
- } else if (Tok == TOK_SET) {
+ } else if (CurTok.Tok == TOK_SET) {
ExprNode* Expr;
* without a colon if there is no whitespace before the
* identifier.
*/
- if (Tok != TOK_COLON) {
+ if (CurTok.Tok != TOK_COLON) {
if (HadWS || !NoColonLabels) {
Error ("`:' expected");
/* Try some smart error recovery */
- if (Tok == TOK_NAMESPACE) {
+ if (CurTok.Tok == TOK_NAMESPACE) {
NextTok ();
}
}
/* If we come here, a new identifier may be waiting, which may
* be a macro or instruction.
*/
- if (Tok == TOK_IDENT) {
+ if (CurTok.Tok == TOK_IDENT) {
if (!UbiquitousIdents) {
/* Macros and symbols cannot use instruction names */
- Instr = FindInstruction (&SVal);
+ Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
- Macro = IsMacro (&SVal);
+ Macro = IsMacro (&CurTok.SVal);
}
} else {
/* Macros and symbols may use the names of instructions */
- Macro = IsMacro (&SVal);
+ Macro = IsMacro (&CurTok.SVal);
}
}
}
}
/* We've handled a possible label, now handle the remainder of the line */
- if (Tok >= TOK_FIRSTPSEUDO && Tok <= TOK_LASTPSEUDO) {
+ if (CurTok.Tok >= TOK_FIRSTPSEUDO && CurTok.Tok <= TOK_LASTPSEUDO) {
/* A control command */
HandlePseudo ();
} else if (Macro) {
/* A macro expansion */
MacExpandStart ();
} else if (Instr >= 0 ||
- (UbiquitousIdents && ((Instr = FindInstruction (&SVal)) >= 0))) {
+ (UbiquitousIdents && ((Instr = FindInstruction (&CurTok.SVal)) >= 0))) {
/* A mnemonic - assemble one instruction */
HandleInstruction (Instr);
- } else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
+ } else if (PCAssignment && (CurTok.Tok == TOK_STAR || CurTok.Tok == TOK_PC)) {
NextTok ();
- if (Tok != TOK_EQ) {
+ if (CurTok.Tok != TOK_EQ) {
Error ("`=' expected");
SkipUntilSep ();
} else {
NextTok ();
/* Assemble lines until end of file */
- while (Tok != TOK_EOF) {
+ while (CurTok.Tok != TOK_EOF) {
OneLine ();
}
}
/* Write the export list */
WriteExports ();
+ /* Write the scopes if requested */
+ WriteScopes ();
+
/* Write debug symbols if requested */
WriteDbgSyms ();
/* Write line infos if requested */
- WriteLineInfo ();
+ WriteLineInfos ();
/* Write the string pool */
WriteStrPool ();
{ "--ignore-case", 0, OptIgnoreCase },
{ "--include-dir", 1, OptIncludeDir },
{ "--list-bytes", 1, OptListBytes },
- { "--listing", 0, OptListing },
+ { "--listing", 1, OptListing },
{ "--macpack-dir", 1, OptMacPackDir },
{ "--memory-model", 1, OptMemoryModel },
{ "--pagelength", 1, OptPageLength },
*/
SymEnterLevel (&GlobalNameSpace, ST_GLOBAL, ADDR_SIZE_DEFAULT);
+ /* Initialize the line infos. Must be done here, since we need line infos
+ * for symbol definitions.
+ */
+ InitLineInfo ();
+
/* Check the parameters */
I = 1;
while (I < ArgCount) {
break;
case 'l':
- OptListing (Arg, 0);
+ OptListing (Arg, GetArg (&I, 2));
break;
case 'm':
break;
case 'o':
- OutFile = GetArg (&I, 2);
+ OutFile = GetArg (&I, 2);
break;
case 's':
break;
case 'U':
- OptAutoImport (Arg, 0);
+ OptAutoImport (Arg, 0);
break;
case 'V':
SegDump ();
}
- /* If we didn't have any errors, create the object, listing and
- * dependency files
+ /* If we didn't have any errors, create the object, listing and
+ * dependency files
*/
if (ErrorCount == 0) {
CreateObjFile ();
- if (Listing) {
+ if (SB_GetLen (&ListingName) > 0) {
CreateListing ();
}
CreateDependencies ();