From 30594ce1f18579b777a9758d24249b2d36725f8c Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 11 Sep 2003 20:19:09 +0000 Subject: [PATCH] New --hexoffs option git-svn-id: svn://svn.cc65.org/cc65/trunk@2433 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/da65/attrtab.c | 5 ++++- src/da65/global.c | 1 + src/da65/global.h | 1 + src/da65/infofile.c | 11 +++++++++++ src/da65/main.c | 11 +++++++++++ src/da65/scanner.h | 1 + 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/da65/attrtab.c b/src/da65/attrtab.c index 005f28477..69efa282a 100644 --- a/src/da65/attrtab.c +++ b/src/da65/attrtab.c @@ -157,6 +157,9 @@ void AddExtLabelRange (unsigned Addr, const char* Name, unsigned Count) if (Count > 1) { unsigned Offs; + /* Setup the format string */ + const char* Format = UseHexOffs? "$%02X" : "%u"; + /* Allocate memory for the dependent label names */ unsigned NameLen = strlen (Name); char* DepName = xmalloc (NameLen + 7); @@ -168,7 +171,7 @@ void AddExtLabelRange (unsigned Addr, const char* Name, unsigned Count) /* Define the labels */ for (Offs = 1; Offs < Count; ++Offs) { - sprintf (DepOffs, "%u", Offs); + sprintf (DepOffs, Format, Offs); AddLabel (Addr + Offs, atDepLabel, DepName); } diff --git a/src/da65/global.c b/src/da65/global.c index 7051d68b8..723dc2516 100644 --- a/src/da65/global.c +++ b/src/da65/global.c @@ -54,6 +54,7 @@ const char CfgExt[] = ".cfg"; /* Config file extension */ /* Flags and other command line stuff */ unsigned char DebugInfo = 0; /* Add debug info to the object file */ unsigned char FormFeeds = 0; /* Add form feeds to the output? */ +unsigned char UseHexOffs = 0; /* Use hexadecimal label offsets */ unsigned char PassCount = 2; /* How many passed do we do? */ long StartAddr = -1L; /* Start/load address of the program */ long InputOffs = -1L; /* Offset into input file */ diff --git a/src/da65/global.h b/src/da65/global.h index 9d46feae4..7d1098a36 100644 --- a/src/da65/global.h +++ b/src/da65/global.h @@ -55,6 +55,7 @@ extern const char CfgExt[]; /* Config file extension */ /* Flags and other command line stuff */ extern unsigned char DebugInfo; /* Add debug info to the object file */ extern unsigned char FormFeeds; /* Add form feeds to the output? */ +extern unsigned char UseHexOffs; /* Use hexadecimal label offsets */ extern unsigned char PassCount; /* How many passed do we do? */ extern long StartAddr; /* Start/load address of the program */ extern long InputOffs; /* Offset into input file */ diff --git a/src/da65/infofile.c b/src/da65/infofile.c index f31be347a..7c9418674 100644 --- a/src/da65/infofile.c +++ b/src/da65/infofile.c @@ -81,6 +81,7 @@ static void GlobalSection (void) static const IdentTok GlobalDefs[] = { { "COMMENTS", INFOTOK_COMMENTS }, { "CPU", INFOTOK_CPU }, + { "HEXOFFS", INFOTOK_HEXOFFS }, { "INPUTNAME", INFOTOK_INPUTNAME }, { "INPUTOFFS", INFOTOK_INPUTOFFS }, { "INPUTSIZE", INFOTOK_INPUTSIZE }, @@ -123,6 +124,16 @@ static void GlobalSection (void) InfoNextTok (); break; + case INFOTOK_HEXOFFS: + InfoNextTok (); + InfoBoolToken (); + switch (InfoTok) { + case INFOTOK_FALSE: UseHexOffs = 0; break; + case INFOTOK_TRUE: UseHexOffs = 1; break; + } + InfoNextTok (); + break; + case INFOTOK_INPUTNAME: InfoNextTok (); InfoAssureStr (); diff --git a/src/da65/main.c b/src/da65/main.c index 631e735b9..95101f40b 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -87,6 +87,7 @@ static void Usage (void) " --debug-info\t\tAdd debug info to object file\n" " --formfeeds\t\tAdd formfeeds to the output\n" " --help\t\tHelp (this text)\n" + " --hexoffs\t\tUse hexadecimal label offsets\n" " --info name\t\tSpecify an info file\n" " --pagelength n\tSet the page length for the listing\n" " --start-addr addr\tSet the start/load address\n" @@ -181,6 +182,15 @@ static void OptHelp (const char* Opt attribute ((unused)), +static void OptHexOffs (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Handle the --hexoffs option */ +{ + UseHexOffs = 1; +} + + + static void OptInfo (const char* Opt attribute ((unused)), const char* Arg) /* Handle the --info option */ { @@ -364,6 +374,7 @@ int main (int argc, char* argv []) { "--debug-info", 0, OptDebugInfo }, { "--formfeeds", 0, OptFormFeeds }, { "--help", 0, OptHelp }, + { "--hexoffs", 0, OptHexOffs }, { "--info", 1, OptInfo }, { "--pagelength", 1, OptPageLength }, { "--start-addr", 1, OptStartAddr }, diff --git a/src/da65/scanner.h b/src/da65/scanner.h index 4d6c37872..4a14d0d5d 100644 --- a/src/da65/scanner.h +++ b/src/da65/scanner.h @@ -67,6 +67,7 @@ typedef enum token_t { /* Global section */ INFOTOK_COMMENTS, INFOTOK_CPU, + INFOTOK_HEXOFFS, INFOTOK_INPUTNAME, INFOTOK_INPUTOFFS, INFOTOK_INPUTSIZE, -- 2.39.5