#include "cmdline.h"
#include "mmodel.h"
#include "print.h"
+#include "scopedefs.h"
#include "strbuf.h"
#include "target.h"
#include "tgttrans.h"
" -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 OptCreateFullDep (const char* Opt attribute ((unused)),
- const char* Arg)
+ const char* Arg)
/* Handle the --create-full-dep option */
{
FileNameOption (Opt, Arg, &FullDepName);
-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);
}
Segment* Seg = 0;
unsigned long PC = 0;
SymEntry* Sym = 0;
- int Macro = 0;
+ Macro* Mac = 0;
int Instr = -1;
/* Initialize the new listing line if we are actually reading from file
InitListingLine ();
}
+ /* Single colon means unnamed label */
if (CurTok.Tok == TOK_COLON) {
- /* An unnamed label */
ULabDef ();
NextTok ();
}
/* Macros and symbols cannot use instruction names */
Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
- Macro = IsMacro (&CurTok.SVal);
+ Mac = FindMacro (&CurTok.SVal);
}
} else {
/* Macros and symbols may use the names of instructions */
- Macro = IsMacro (&CurTok.SVal);
+ Mac = FindMacro (&CurTok.SVal);
}
}
*/
if (CurTok.Tok == TOK_LOCAL_IDENT ||
CurTok.Tok == TOK_NAMESPACE ||
- (CurTok.Tok == TOK_IDENT && Instr < 0 && !Macro)) {
+ (CurTok.Tok == TOK_IDENT && Instr < 0 && Mac == 0)) {
/* Did we have whitespace before the ident? */
int HadWS = CurTok.WS;
/* Macros and symbols cannot use instruction names */
Instr = FindInstruction (&CurTok.SVal);
if (Instr < 0) {
- Macro = IsMacro (&CurTok.SVal);
+ Mac = FindMacro (&CurTok.SVal);
}
} else {
/* Macros and symbols may use the names of instructions */
- Macro = IsMacro (&CurTok.SVal);
+ Mac = FindMacro (&CurTok.SVal);
}
}
}
if (CurTok.Tok >= TOK_FIRSTPSEUDO && CurTok.Tok <= TOK_LASTPSEUDO) {
/* A control command */
HandlePseudo ();
- } else if (Macro) {
+ } else if (Mac != 0) {
/* A macro expansion */
- MacExpandStart ();
+ MacExpandStart (Mac);
} else if (Instr >= 0 ||
(UbiquitousIdents && ((Instr = FindInstruction (&CurTok.SVal)) >= 0))) {
/* A mnemonic - assemble one instruction */
/* Write the export list */
WriteExports ();
- /* Write the scopes if requested */
- WriteScopes ();
-
/* Write debug symbols if requested */
WriteDbgSyms ();
+ /* Write the scopes if requested */
+ WriteScopes ();
+
/* Write line infos if requested */
WriteLineInfos ();
{ "--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 },
/* Initialize the include search paths */
InitIncludePaths ();
+ /* Create the predefined segments */
+ SegInit ();
+
/* Enter the base lexical level. We must do that here, since we may
* define symbols using -D.
*/
- SymEnterLevel (&GlobalNameSpace, ST_GLOBAL, ADDR_SIZE_DEFAULT);
+ SymEnterLevel (&GlobalNameSpace, SCOPE_FILE, ADDR_SIZE_DEFAULT, 0);
- /* Initialize the line infos. Must be done here, since we need line infos
+ /* Initialize the line infos. Must be done here, since we need line infos
* for symbol definitions.
*/
InitLineInfo ();
break;
case 'l':
- OptListing (Arg, 0);
+ OptListing (Arg, GetArg (&I, 2));
break;
case 'm':
SetMemoryModel (MMODEL_NEAR);
}
- /* Initialize the segments */
- InitSegments ();
+ /* Set the default segment sizes according to the memory model */
+ SetSegmentSizes ();
/* Initialize the scanner, open the input file */
InitScanner (InFile);
CheckPseudo ();
}
- /* If we didn't have any errors, check the unnamed labels */
+ /* If we didn't have any errors, check and cleanup the unnamed labels */
if (ErrorCount == 0) {
- ULabCheck ();
+ ULabDone ();
}
/* If we didn't have any errors, check the symbol table */
SymCheck ();
}
+ /* If we didn't have any errors, close the file scope lexical level */
+ if (ErrorCount == 0) {
+ SymLeaveLevel ();
+ }
+
/* If we didn't have any errors, check and resolve the segment data */
if (ErrorCount == 0) {
- SegCheck ();
+ SegDone ();
}
- /* If we didn't have any errors, check the assertions */
+ /* If we didn't have any errors, check the assertions */
if (ErrorCount == 0) {
CheckAssertions ();
}
- /* If we didn't have an errors, index the line infos */
- MakeLineInfoIndex ();
-
/* Dump the data */
if (Verbosity >= 2) {
SymDump (stdout);
SegDump ();
}
+ /* If we didn't have an errors, finish off the line infos */
+ DoneLineInfo ();
+
/* 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 ();