unsigned rflag = 0; // Segment alignment size flag
unsigned sflag = 0; // Output only global symbols
unsigned vflag = 0; // Verbose flag
+unsigned wflag = 0; // Show warnings flag
unsigned zflag = 0; // Suppress banner flag
-unsigned pflag, uflag, wflag = 1; // Unimplemented flags
+unsigned pflag, uflag; // Unimplemented flags
unsigned hd = 0; // Index of next file handle to fill
unsigned secalign = 7; // Section Alignment (8=phrase)
unsigned tbase = 0; // TEXT base address
//
int dosym(struct OFILE * ofile)
{
- char * symptr; // Symbol pointer
- char * symend; // Symbol end pointer
- int type; // Symbol type
- long value; // Symbol value
- int index; // Symbol index
- int j; // Iterator
- int ssidx; // Segment size table index
- unsigned tsegoffset; // Cumulative TEXT segment offset
- unsigned dsegoffset; // Cumulative DATA segment offset
- unsigned bsegoffset; // Cumulative BSS segment offset
- struct HREC * hptr; // Hash table pointer for globl/extrn
- char sym[SYMLEN]; // String for symbol name/hash search
+ char * symptr; // Symbol pointer
+ char * symend; // Symbol end pointer
+ int type; // Symbol type
+ long value; // Symbol value
+ int index; // Symbol index
+ int j; // Iterator
+ int ssidx; // Segment size table index
+ unsigned tsegoffset; // Cumulative TEXT segment offset
+ unsigned dsegoffset; // Cumulative DATA segment offset
+ unsigned bsegoffset; // Cumulative BSS segment offset
+ struct HREC * hptr; // Hash table pointer for globl/extrn
+ char sym[SYMLEN]; // String for symbol name/hash search
// Point to first symbol record in the object file
symptr = (ofile->o_image + 32
ssidx = -1; // Initialise segment index
tsegoffset = dsegoffset = bsegoffset = 0; // Initialise segment offsets
+ // Search for object file name
for(j=0; j<(int)obj_index; j++)
- { // Search for object file name
+ {
if (!strcmp(ofile->o_name, obj_fname[j]))
{
ssidx = j; // Object file name found
// Global/External symbols have a pre-processing stage
if (type & 0x01000000)
{
- // Obtain the string table index for the relocation symbol, look for it in the globals
- // hash table to obtain information on that symbol. For the hash calculation to work
- // correctly it must be placed in a 'clean' string before looking it up.
+ // Obtain the string table index for the relocation symbol, look
+ // for it in the globals hash table to obtain information on that
+ // symbol. For the hash calculation to work correctly it must be
+ // placed in a 'clean' string before looking it up.
memset(sym, 0, SYMLEN);
strcpy(sym, symend + index);
hptr = lookup(sym);
return 1;
}
- // Search through object segment size table to obtain segment sizes for the object
- // that has the required external/global as a local symbol. As each object is
- // interrogated the segment sizes are accumulated to ensure the correct offsets are
- // used in the resulting COF file. This is effectively 'done again' only as we
+ // Search through object segment size table to obtain segment sizes
+ // for the object that has the required external/global as a local
+ // symbol. As each object is interrogated the segment sizes are
+ // accumulated to ensure the correct offsets are used in the
+ // resulting COF file. This is effectively 'done again' only as we
// are working with a different object file.
ssidx = -1; // Initialise segment index
tsegoffset = dsegoffset = bsegoffset = 0; // Initialise segment offsets
if (type == 0x03000000)
type = 0x02000000; // Reset external flag if absolute
- // If the global/external has a value then update that vaule in accordance with the
- // segment sizes of the object file it originates from
+ // If the global/external has a value then update that vaule in
+ // accordance with the segment sizes of the object file it
+ // originates from
if (hptr->h_value)
{
switch (hptr->h_type & 0x0E000000)
}
}
- // Process and update the value dependant on whether the symbol is a debug symbol or not
+ // Process and update the value dependant on whether the symbol is a
+ // debug symbol or not
if (type & 0xF0000000)
{ // DEBUG SYMBOL
// Set the correct debug symbol base address (TEXT segment)
putlong(symptr + 8, value);
}
else
- { // NON-DEBUG SYMBOL
- // Now make modifications to the symbol value, local or global, based on the segment sizes
- // of the object file currently being processed.
+ {
+ // NON-DEBUG SYMBOL
+ // Now make modifications to the symbol value, local or global,
+ // based on the segment sizes of the object file currently being
+ // processed.
switch (type & T_SEG)
{
case 0x02000000: // Absolute value
value = bbase + bsegoffset + value;
else
value = bbase + bsegoffset
- +(value - (ofile->o_header.tsize + ofile->o_header.dsize));
+ + (value - (ofile->o_header.tsize + ofile->o_header.dsize));
putlong(symptr + 8, value);
break;
}
}
- dosymi++; // Increment dosym() processsing
+ // Increment dosym() processsing
+ dosymi++;
+
return 0;
}
}
}
-#if 0
-if ((strcmp(name, "U235SE_playback_rate") == 0)
- || (strcmp(name, "U235SE_playback_period") == 0))
-{
- printf("%s found: ost[0]=$%08X, ost[1]=$%08X, ost[2]=$%08X\n", name, getlong(ost_ptr), type, value);
-}
-#endif
// If this is a debug symbol and the include debug symbol flag (-g) is not
// set then do nothing
if ((type & 0xF0000000) && !gflag)
{
// Do nothing
-#if 0
-if ((strcmp(name, "U235SE_playback_rate") == 0)
- || (strcmp(name, "U235SE_playback_period") == 0))
- printf("%s was IGNORED!\n", name);
-#endif
}
else
{
if (((ostresult != -1) && bflag && !(type & 0x01000000))
|| ((ostresult != -1) && gflag && (type & 0xF0000000)) || (ostresult == -1))
{
-#if 0
-if ((strcmp(name, "U235SE_playback_rate") == 0)
- || (strcmp(name, "U235SE_playback_period") == 0))
- printf("%s was added to the ost.\n", name);
-#endif
if ((type & 0xF0000000) == 0x40000000)
putlong(ost_ptr, 0x00000000); // Zero string table offset for dbg line
else
for(i=0; i<ost_index; i++)
{
if (strcmp(oststr + stro, sym) == 0)
- {
-#if 0
- // Shamus: More debug stuffs...
- if (vflag > 1)
- {
- printf("ost_lookup(): Found @ %i (looking for '%s', found '%s')\n", i, sym, oststr + stro);
- }
-#endif
-
return i + 1;
- }
stro += strlen(oststr + stro) + 1;
}
{
if (ost_add(hptr->h_sym, T_EXT, 0L) == -1)
return 1;
-printf("dounresolved(): added %s\n",hptr->h_sym);
+
+ if (vflag > 1)
+ printf("dounresolved(): added %s\n", hptr->h_sym);
+
htemp = hptr->h_next; // Temporarily get ptr to next record
free(hptr); // Free current record
hptr = htemp; // Make next record ptr, current
olddata = newdata = 0; // Initialise old and new segment data
ssidx = ost_lookup(sym);
newdata = getlong(ost + ((ssidx - 1) * 12) + 8);
-//nope, false lead. -0 & -2 give bad results
-// newdata = getlong(ost + ((ssidx - 2) * 12) + 8);
}
// Obtain the existing long word segment data and flip words if the
// Reached maximum file handles
if (hd == NHANDLES)
{
- if (flush_handles()) return 1;
+ if (flush_handles())
+ return 1;
}
// Attempt to open input file
// Absolute (ABS) symbol/string table
else
{
- // The symbol and string table have been created as part of the dosym() function and the
- // output symbol and string tables are in COF format. For an ABS file we need to process
- // through this to create the 14 character long combined symbol and string table.
- // Format of symbol table in ABS: AAAAAAAATTVVVV, where (A)=STRING, (T)=TYPE & (V)=VALUE
+ // The symbol and string table have been created as part of the
+ // dosym() function and the output symbol and string tables are in
+ // COF format. For an ABS file we need to process through this to
+ // create the 14 character long combined symbol and string table.
+ // Format of symbol table in ABS: AAAAAAAATTVVVV, where (A)=STRING,
+ // (T)=TYPE & (V)=VALUE
for(i=0; i<ost_index; i++)
{
- memset(symbol, 0, 14); // Initialise symbol record
- abstype = 0; // Initialise ABS symbol type
- slen = 0; // Initialise symbol string length
- index = getlong(ost + (i * 12)); // Get symbol index
- type = getlong((ost + (i * 12)) + 4); // Get symbol type
+ memset(symbol, 0, 14); // Initialise symbol record
+ abstype = 0; // Initialise ABS symbol type
+ slen = 0; // Initialise symbol string length
+ index = getlong(ost + (i * 12)); // Get symbol index
+ type = getlong((ost + (i * 12)) + 4); // Get symbol type
if (type & 0xF0000000)
continue; // Not doing debug symbols
- value = getlong((ost + (i * 12)) + 8); // Get symbol value
+ value = getlong((ost + (i * 12)) + 8); // Get symbol value
slen = strlen(oststr + index);
// Get symbol string (maximum 8 chars)
break;
}
- putword(symbol + 8, abstype); // Write back new ABS type
- putlong(symbol + 10, value); // Write back value
+ putword(symbol + 8, abstype); // Write back new ABS type
+ putlong(symbol + 10, value); // Write back value
if (fwrite(symbol, 14, 1, fd) != 1) goto werror; // Write symbol record
}
printf("Close error on output file %s\n",ofile);
return 1;
}
- else
- return 0;
-werror: // OMG! Why did Atari use these :)
+ return 0;
+
+werror: // OMG! Why did Atari use these :)
printf("Write error on output file %s\n", ofile);
- fclose(fd); // Try to close output file anyway
+ fclose(fd); // Try to close output file anyway
return 1;
}
//
struct OHEADER * make_ofile()
{
- unsigned tptr, dptr, bptr; // Bases in runtime model
- int ret = 0; // Return value
- struct OFILE * otemp, * oprev, * ohold; // Object file list pointers
- struct OHEADER * header; // Output header pointer
+ unsigned tptr, dptr, bptr; // Bases in runtime model
+ int ret = 0; // Return value
+ struct OFILE * otemp, * oprev, * ohold; // Object file list pointers
+ struct OHEADER * header; // Output header pointer
- textsize = datasize = bsssize = 0; // Initialise cumulative segment sizes
+ textsize = datasize = bsssize = 0; // Initialise cumulative segment sizes
- // For each object file, accumulate the sizes of the segments but remove those
- // object files which are unused
- oprev = NULL; // Init previous obj file list ptr
- otemp = olist; // Set temp pointer to object file list
+ // For each object file, accumulate the sizes of the segments but remove
+ // those object files which are unused
+ oprev = NULL; // Init previous obj file list ptr
+ otemp = olist; // Set temp pointer to object file list
while (otemp != NULL)
{
}
}
- otemp = otemp->o_next; // Go to next object file list pointer
+ otemp = otemp->o_next; // Go to next object file list pointer
}
// Update base addresses and create symbols _TEXT_E, _DATA_E and _BSS_E
if (dounresolved())
return NULL;
- tptr = 0; // Initialise base addresses
+ tptr = 0; // Initialise base addresses
dptr = 0;
bptr = 0;
//
int add_to_hlist(struct HREC ** hptr, char * sym, struct OFILE * ofile, long value, int type)
{
- struct HREC * htemp; // Temporary hash record pointer
+ struct HREC * htemp; // Temporary hash record pointer
int i;
// Attempt to allocate new hash record
// Shamus: Moar testing...
if (vflag > 1)
{
- printf("add_to_hlist(): hptr=$%08X, sym=\"%s\", ofile=$%08X, value=%li, type=%i", (unsigned int)hptr, sym, (unsigned int)ofile, value, type);
+ printf("add_to_hlist(): hptr=$%08X, sym=\"%s\", ofile=$%08X, value=$%X, type=$%X\n", (unsigned int)hptr, sym, (unsigned int)ofile, value, type);
}
for(i=0; i<SYMLEN; i++)
htemp->h_sym[i] = '\0';
- strcpy(htemp->h_sym, sym); // Populate hash record
+ strcpy(htemp->h_sym, sym); // Populate hash record
htemp->h_ofile = ofile;
htemp->h_value = value;
htemp->h_type = type;
- htemp->h_next = *hptr; // Update hash record pointers
+ htemp->h_next = *hptr; // Update hash record pointers
*hptr = htemp;
return 0;
if (vflag > 1)
{
- printf("hash_add(%s,%s,%lx,", sym, ofile->o_name,value);
+ printf("hash_add(%s,%s,%lx,", sym, ofile->o_name, value);
printf("%x,%s)\n", (unsigned int)type, (flag ? "GLOBAL" : "COMMON"));
}
return add_to_hlist(&htable[dohash(sym)], sym, ofile, value, type);
}
-
// Already there!
if (iscommon(type) && !iscommon(hptr->h_type))
{
// Mismatch: global came first; warn and keep the global one
if (wflag)
{
- printf("Warning: %s: global from ",sym);
+ printf("Warning: %s: global from ", sym);
put_name(hptr->h_ofile);
printf(" used, common from ");
put_name(ofile);
hptr->h_ofile = ofile;
hptr->h_value = value;
}
+ // They're both global
else if (flag)
- { // They're both global
+ {
// Global exported by another ofile; warn and make this one extern
if (wflag)
{
putword(sym + 8, ABST_EXTERN);
}
+ // They're both common
else
- { // They're both common
+ {
if (hptr->h_value < value)
{
hptr->h_value = value;
// Round BSS off to alignment boundary
Ofile->o_header.bsize = (Ofile->o_header.bsize + secalign) & ~secalign;
- if (Ofile->o_header.dsize & 7)
+ if ((Ofile->o_header.dsize & 7) && wflag)
{
printf("Warning: data segment size of ");
put_name(Ofile);
//
char * path_tail(char * name)
{
- char * temp = max(strrchr(name,'/'), max(strrchr(name,':'), strrchr(name, 92)));
+// char * temp = MAX(strrchr(name, '/'), MAX(strrchr(name, ':'), strrchr(name, '\\')));
+ char * temp = strrchr(name, PATH_DELIMITER);
+ // Return what was passed in if path delimiter was not found
if (temp == NULL)
- temp = (name - 1);
+ return name;
return temp + 1;
}
{
if (plist == NULL)
{
- plist = new_ofile(); // First time object record allocation
- plast = plist; // Update last object record pointer
+ plist = new_ofile(); // First time object record allocation
+ plast = plist; // Update last object record pointer
}
else
{
- plast->o_next = new_ofile(); // Next object record allocation
- plast = plast->o_next; // Update last object record pointer
+ plast->o_next = new_ofile(); // Next object record allocation
+ plast = plast->o_next; // Update last object record pointer
}
if (plast == NULL)
{
- printf("Out of memory.\n"); // Error if memory allocation fails
+ printf("Out of memory.\n"); // Error if memory allocation fails
return 1;
}
- if (strlen(path_tail(fname)) > FNLEN-1)
- { // Error on excessive filename length
- printf("File name too long: %s (sorry!)\n",fname);
+ if (strlen(path_tail(fname)) > FNLEN - 1)
+ {
+ // Error on excessive filename length
+ printf("File name too long: %s (sorry!)\n", fname);
return 1;
}
- strcpy(plast->o_name, path_tail(fname)); // Store filename, not path
- *plast->o_arname = 0; // No archive name for this file
- plast->o_image = ptr; // Store data pointer
- plast->o_flags = O_USED; // File is used
- plast->o_next = NULL; // Initialise next record pointer
+ strcpy(plast->o_name, path_tail(fname)); // Store filename, not path
+ *plast->o_arname = 0; // No archive name for this file
+ plast->o_image = ptr; // Store data pointer
+ plast->o_flags = O_USED; // File is used
+ plast->o_next = NULL; // Initialise next record pointer
- return 0; // Return without errors
+ return 0; // Return without errors
}
unsigned symtype = 0;
fsize = FSIZE(handle); // Get size of include file
- dsize = (fsize+secalign) & ~secalign; // Round up to a alignment boundary
+ dsize = (fsize + secalign) & ~secalign; // Round up to a alignment boundary
sym1len = strlen(sym1) + 1; // Get sym1 length + null termination
sym2len = strlen(sym2) + 1; // Get sym2 length + null termination
}
// Read in binary data
- if (read(handle, ptr+32, fsize) != fsize)
+ if (read(handle, ptr + 32, fsize) != fsize)
{
printf("File read error on %s\n", fname);
close(handle);
//
int doargs(int argc, char * argv[])
{
- int i = 1; // Iterator
- int c; // Command line character
- char * ifile, * isym; // File name and symbol name for -i
-
- while (i < argc)
- { // Parse through option switches & files
- if (argv[i][0] == '-')
- { // Process command line switches
- if (!argv[i][1])
- {
- printf("Illegal option argument: %s\n\n", argv[i]);
- display_help();
- return 1;
- }
-
- c = argv[i++][1]; // Get next character in command line
-
- switch (c)
- { // Process command line switch
- case '?': // Display usage information
- case 'h':
+ int i = 1; // Iterator
+ int c; // Command line character
+ char * ifile, * isym; // File name and symbol name for -i
+
+ while (i < argc)
+ { // Parse through option switches & files
+ if (argv[i][0] == '-')
+ { // Process command line switches
+ if (!argv[i][1])
+ {
+ printf("Illegal option argument: %s\n\n", argv[i]);
+ display_help();
+ return 1;
+ }
+
+ c = argv[i++][1]; // Get next character in command line
+
+ switch (c)
+ { // Process command line switch
+ case '?': // Display usage information
+ case 'h':
case 'H':
- display_version();
- display_help();
- return 1;
- case 'a':
+ display_version();
+ display_help();
+ return 1;
+ case 'a':
case 'A': // Set absolute linking on
- if (aflag)
- warn('a', 1);
-
- if (i + 2 >= argc)
- {
- printf("Not enough arguments to -a\n");
- return 1;
- }
-
- aflag = 1; // Set abs link flag
- // Segment order is TEXT, DATA, BSS
- // Text segment can be 'r', 'x' or a value
- ttype = 0;
-
- if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
- {
- ttype = -1; // TEXT segment is relocatable
- }
- else if ((*argv[i] == 'x' || *argv[i] == 'X'))
- {
- printf("Error in text-segment address: cannot be contiguous\n");
- return 1;
- }
- else if ((ttype = 0), getval(argv[i], &tval))
- {
- printf("Error in text-segment address: %s is not 'r', 'x' or an address.", argv[i]);
- return 1;
- }
-
- i++;
- // Data segment can be 'r', 'x' or a value
- dtype = 0;
-
- if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
- {
- dtype = -1; // DATA segment is relocatable
- }
- else if ((*argv[i] == 'x' || *argv[i] == 'X'))
- {
- dtype = -2; // DATA follows TEXT
- }
- else if ((dtype = 0), getval(argv[i],&dval))
- {
- printf("Error in data-segment address: %s is not 'r', 'x' or an address.", argv[i]);
- return 1;
- }
-
- i++;
- btype = 0;
-
- // BSS segment can be 'r', 'x' or a value
- if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
- {
- btype = -1; // BSS segment is relocatable
- }
- else if ((*argv[i] == 'x' || *argv[i] == 'X'))
- {
- btype = -3; // BSS follows DATA
- }
- else if ((btype = 0), getval(argv[i],&bval))
- {
- printf("Error in bss-segment address: %s is not 'r', 'x[td]', or an address.", argv[i]);
- return 1;
- }
-
- i++;
- break;
- case 'b':
+ if (aflag)
+ warn('a', 1);
+
+ if (i + 2 >= argc)
+ {
+ printf("Not enough arguments to -a\n");
+ return 1;
+ }
+
+ aflag = 1; // Set abs link flag
+ // Segment order is TEXT, DATA, BSS
+ // Text segment can be 'r', 'x' or a value
+ ttype = 0;
+
+ if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
+ {
+ ttype = -1; // TEXT segment is relocatable
+ }
+ else if ((*argv[i] == 'x' || *argv[i] == 'X'))
+ {
+ printf("Error in text-segment address: cannot be contiguous\n");
+ return 1;
+ }
+ else if ((ttype = 0), getval(argv[i], &tval))
+ {
+ printf("Error in text-segment address: %s is not 'r', 'x' or an address.", argv[i]);
+ return 1;
+ }
+
+ i++;
+ // Data segment can be 'r', 'x' or a value
+ dtype = 0;
+
+ if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
+ {
+ dtype = -1; // DATA segment is relocatable
+ }
+ else if ((*argv[i] == 'x' || *argv[i] == 'X'))
+ {
+ dtype = -2; // DATA follows TEXT
+ }
+ else if ((dtype = 0), getval(argv[i],&dval))
+ {
+ printf("Error in data-segment address: %s is not 'r', 'x' or an address.", argv[i]);
+ return 1;
+ }
+
+ i++;
+ btype = 0;
+
+ // BSS segment can be 'r', 'x' or a value
+ if ((*argv[i] == 'r' || *argv[i] == 'R') && !argv[i][1])
+ {
+ btype = -1; // BSS segment is relocatable
+ }
+ else if ((*argv[i] == 'x' || *argv[i] == 'X'))
+ {
+ btype = -3; // BSS follows DATA
+ }
+ else if ((btype = 0), getval(argv[i],&bval))
+ {
+ printf("Error in bss-segment address: %s is not 'r', 'x[td]', or an address.", argv[i]);
+ return 1;
+ }
+
+ i++;
+ break;
+ case 'b':
case 'B': // Don't remove muliply defined locals
- if (bflag)
- warn('b', 1);
+ if (bflag)
+ warn('b', 1);
- bflag = 1;
- break;
- case 'c':
+ bflag = 1;
+ break;
+ case 'c':
case 'C': // Process a command file
- if (i == argc)
- {
- printf("Not enough arguments to -c\n");
- return 1;
- }
-
- if (docmdfile(argv[i++]))
- {
- return 1;
- }
-
- break;
- case 'd':
+ if (i == argc)
+ {
+ printf("Not enough arguments to -c\n");
+ return 1;
+ }
+
+ if (docmdfile(argv[i++]))
+ {
+ return 1;
+ }
+
+ break;
+ case 'd':
case 'D': // Wait for "return" before exiting
- if (dflag)
- warn('d', 0);
+ if (dflag)
+ warn('d', 0);
- dflag = 1;
- waitflag = 1;
- break;
- case 'e':
+ dflag = 1;
+ waitflag = 1;
+ break;
+ case 'e':
case 'E': // Output COFF (absolute only)
- cflag = 1;
- break;
- case 'g':
+ cflag = 1;
+ break;
+ case 'g':
case 'G': // Output source level debugging
- printf("\'g\' flag not currently implemented\n");
- gflag = 0;
- /*
- if (gflag) warn('g', 1);
- gflag = 1;
- */
- break;
- case 'i':
+ printf("\'g\' flag not currently implemented\n");
+ gflag = 0;
+ /*
+ if (gflag) warn('g', 1);
+ gflag = 1;
+ */
+ break;
+ case 'i':
case 'I': // Include binary file
- if (i + 2 > argc)
- {
- printf("Not enough arguments to -i\n");
- return 1;
- }
-
- ifile = argv[i++];
- isym = argv[i++];
-
- if ((argv[i-3][2] == 'i') || (argv[i-3][2] == 'I'))
- { // handle -ii (No truncation)
- if (!cflag)
- printf("warning: (-ii) COFF format output not specified\n");
- }
- else
- { // handle -i (Truncation)
- if (strlen(isym) > 7)
- isym[7] = '\0';
- }
-
- // Place include files in the DATA segment only
- if (dofile(ifile, DSTSEG_D, isym))
- return 1;
-
- break;
- case 'l':
+ if (i + 2 > argc)
+ {
+ printf("Not enough arguments to -i\n");
+ return 1;
+ }
+
+ ifile = argv[i++];
+ isym = argv[i++];
+
+ if ((argv[i-3][2] == 'i') || (argv[i-3][2] == 'I'))
+ { // handle -ii (No truncation)
+ if (!cflag)
+ printf("warning: (-ii) COFF format output not specified\n");
+ }
+ else
+ { // handle -i (Truncation)
+ if (strlen(isym) > 7)
+ isym[7] = '\0';
+ }
+
+ // Place include files in the DATA segment only
+ if (dofile(ifile, DSTSEG_D, isym))
+ return 1;
+
+ break;
+ case 'l':
case 'L': // Add local symbols
- if (lflag)
- warn('l', 1);
+ if (lflag)
+ warn('l', 1);
- lflag = 1;
- break;
- case 'm':
+ lflag = 1;
+ break;
+ case 'm':
case 'M': // Produce load symbol map
- if (mflag)
- warn('m', 1);
+ if (mflag)
+ warn('m', 1);
- mflag = 1;
- break;
- case 'n':
+ mflag = 1;
+ break;
+ case 'n':
case 'N': // Output no header to .abs file
- if (noheaderflag)
- warn('n', 1);
+ if (noheaderflag)
+ warn('n', 1);
- noheaderflag = 1;
- break;
- case 'o':
+ noheaderflag = 1;
+ break;
+ case 'o':
case 'O': // Specify an output file
- if (oflag)
- warn('o', 1);
-
- oflag = 1;
-
- if (i >= argc)
- {
- printf("No output filename following -o switch\n");
- return 1;
- }
-
- if (strlen(argv[i]) > FARGSIZE - 5)
- {
- printf("Output file name too long (sorry!)\n");
- return 1;
- }
-
- strcpy(ofile, argv[i++]);
- break;
- case 'r':
+ if (oflag)
+ warn('o', 1);
+
+ oflag = 1;
+
+ if (i >= argc)
+ {
+ printf("No output filename following -o switch\n");
+ return 1;
+ }
+
+ if (strlen(argv[i]) > FARGSIZE - 5)
+ {
+ printf("Output file name too long (sorry!)\n");
+ return 1;
+ }
+
+ strcpy(ofile, argv[i++]);
+ break;
+ case 'r':
case 'R': // Section alignment size
- if (rflag)
- warn('r', 1);
-
- rflag = 1;
-
- switch (argv[i-1][2])
- {
- case 'w': case 'W': secalign = 1; break; // Word alignment
- case 'l': case 'L': secalign = 3; break; // Long alignment
- case 'p': case 'P': secalign = 7; break; // Phrase alignment
- case 'd': case 'D': secalign = 15; break; // Double phrase alignment
- case 'q': case 'Q': secalign = 31; break; // Quad phrase alignment
- default: secalign = 7; break; // Default phrase alignment
- }
-
- break;
- case 's':
+ if (rflag)
+ warn('r', 1);
+
+ rflag = 1;
+
+ switch (argv[i-1][2])
+ {
+ case 'w': case 'W': secalign = 1; break; // Word alignment
+ case 'l': case 'L': secalign = 3; break; // Long alignment
+ case 'p': case 'P': secalign = 7; break; // Phrase alignment
+ case 'd': case 'D': secalign = 15; break; // Double phrase alignment
+ case 'q': case 'Q': secalign = 31; break; // Quad phrase alignment
+ default: secalign = 7; break; // Default phrase alignment
+ }
+
+ break;
+ case 's':
case 'S': // Output only global symbols
- if (sflag)
- warn('s', 1);
+ if (sflag)
+ warn('s', 1);
- sflag = 1;
- break;
- case 'v':
+ sflag = 1;
+ break;
+ case 'v':
case 'V': // Verbose information
- if (!vflag && !versflag)
- {
- display_version();
- }
-
- vflag++;
- break;
- case 'z':
+ if (!vflag && !versflag)
+ {
+ display_version();
+ }
+
+ vflag++;
+ break;
+ case 'w':
+ case 'W': // Show warnings flag
+ if (wflag)
+ warn('w', 1);
+
+ wflag = 1;
+ break;
+ case 'z':
case 'Z': // Suppress banner flag
- if (zflag)
- warn('z', 1);
-
- zflag = 1;
- break;
- default:
- printf("unknown option argument `%c'\n", c);
- return 1;
- }
- }
- else
- { // Not a switch, then process as a file
- if (dofile(argv[i++], 0, NULL))
- return 1;
- }
-
- }
-
- if (!oflag && vflag)
- {
- strcpy(ofile, "output");
- printf("Output file is %s[.ext]\n", ofile);
- }
-
- if (oflag && vflag)
- printf("Output file is %s\n", ofile);
-
- if (sflag)
- lflag = 0;
-
- return 0; // No problems encountered
+ if (zflag)
+ warn('z', 1);
+
+ zflag = 1;
+ break;
+ default:
+ printf("unknown option argument `%c'\n", c);
+ return 1;
+ }
+ }
+ else
+ { // Not a switch, then process as a file
+ if (dofile(argv[i++], 0, NULL))
+ return 1;
+ }
+
+ }
+
+ if (!oflag && vflag)
+ {
+ strcpy(ofile, "output");
+ printf("Output file is %s[.ext]\n", ofile);
+ }
+
+ if (oflag && vflag)
+ printf("Output file is %s\n", ofile);
+
+ if (sflag)
+ lflag = 0;
+
+ return 0; // No problems encountered
}
printf(" q: quad phrase (32 bytes)\n");
printf(" -s output only global symbols\n");
printf(" -v set verbose mode\n");
+ printf(" -w show linker warnings\n");
printf(" -z suppress banner\n");
printf("\n");
}
// Wait for return key if requested
if (waitflag)
{
- printf("\nPress the <return> key to continue. ");
+ printf("\nPress the [RETURN] key to continue. ");
fgets(tempbuf, 128, stdin);
}