Fixed several obvious omissions. Allow specifying a start address.

git-svn-id: svn://svn.cc65.org/cc65/trunk@570 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2000-12-09 10:10:07 +00:00
parent b2b7fb4b33
commit 61a1fa52c4
7 changed files with 89 additions and 11 deletions

View File

@@ -60,7 +60,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -76,20 +76,49 @@ static void Usage (void)
" -o name\t\tName the output file\n"
" -v\t\t\tIncrease verbosity\n"
" -F\t\t\tAdd formfeeds to the output\n"
" -V\t\t\tPrint the assembler version\n"
" -S addr\t\tSet the start/load address\n"
" -V\t\t\tPrint the disassembler version\n"
"\n"
"Long options:\n"
" --cpu type\t\tSet cpu type\n"
" --formfeeds\t\tAdd formfeeds to the output\n"
" --help\t\tHelp (this text)\n"
" --pagelength n\tSet the page length for the listing\n"
" --start-addr addr\tSet the start/load address\n"
" --verbose\t\tIncrease verbosity\n"
" --version\t\tPrint the assembler version\n",
" --version\t\tPrint the disassembler version\n",
ProgName);
}
static unsigned long CvtNumber (const char* Arg, const char* Number)
/* Convert a number from a string. Allow '$' and '0x' prefixes for hex
* numbers.
*/
{
unsigned long Val;
int Converted;
/* Convert */
if (*Number == '$') {
++Number;
Converted = sscanf (Number, "%lx", &Val);
} else {
Converted = sscanf (Number, "%li", (long*)&Val);
}
/* Check if we do really have a number */
if (Converted != 1) {
Error ("Invalid number given in argument: %s\n", Arg);
}
/* Return the result */
return Val;
}
static void OptCPU (const char* Opt, const char* Arg)
/* Handle the --cpu option */
{
@@ -146,6 +175,14 @@ static void OptPageLength (const char* Opt, const char* Arg)
static void OptStartAddr (const char* Opt, const char* Arg)
/* Set the default start address */
{
StartAddr = CvtNumber (Opt, Arg);
}
static void OptVerbose (const char* Opt, const char* Arg)
/* Increase verbosity */
{
@@ -280,6 +317,7 @@ int main (int argc, char* argv [])
{ "--formfeeds", 0, OptFormFeeds },
{ "--help", 0, OptHelp },
{ "--pagelength", 1, OptPageLength },
{ "--start-addr", 1, OptStartAddr },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
};
@@ -316,6 +354,10 @@ int main (int argc, char* argv [])
OptVerbose (Arg, 0);
break;
case 'S':
OptStartAddr (Arg, GetArg (&I, 2));
break;
case 'V':
OptVersion (Arg, 0);
break;
@@ -359,7 +401,7 @@ int main (int argc, char* argv [])
}
/* Load the input file */
LoadCode (InFile, 0xE000); /* ### */
LoadCode (InFile, StartAddr);
/* Open the output file */
OpenOutput (OutFile);