mirror of
https://github.com/cc65/cc65.git
synced 2025-01-13 09:31:53 +00:00
New features: DByteTable, Comments
git-svn-id: svn://svn.cc65.org/cc65/trunk@2409 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
ece067b0e7
commit
e3d3a43c3c
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000 Ullrich von Bassewitz */
|
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Römerstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -112,7 +112,7 @@ void MarkAddr (unsigned Addr, attr_t Attr)
|
|||||||
const char* MakeLabelName (unsigned Addr)
|
const char* MakeLabelName (unsigned Addr)
|
||||||
/* Make the default label name from the given address and return it in a
|
/* Make the default label name from the given address and return it in a
|
||||||
* static buffer.
|
* static buffer.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
static char LabelBuf [32];
|
static char LabelBuf [32];
|
||||||
xsprintf (LabelBuf, sizeof (LabelBuf), "L%04X", Addr);
|
xsprintf (LabelBuf, sizeof (LabelBuf), "L%04X", Addr);
|
||||||
@ -145,6 +145,40 @@ void AddLabel (unsigned Addr, attr_t Attr, const char* Name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AddExtLabelRange (unsigned Addr, const char* Name, unsigned Count)
|
||||||
|
/* Add an external label for a range. The first entry gets the label "Name"
|
||||||
|
* while the others get "Name+offs".
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
/* Define the label */
|
||||||
|
AddLabel (Addr, atExtLabel, Name);
|
||||||
|
|
||||||
|
/* Define dependent labels if necessary */
|
||||||
|
if (Count > 1) {
|
||||||
|
unsigned Offs;
|
||||||
|
|
||||||
|
/* Allocate memory for the dependent label names */
|
||||||
|
unsigned NameLen = strlen (Name);
|
||||||
|
char* DepName = xmalloc (NameLen + 7);
|
||||||
|
char* DepOffs = DepName + NameLen + 1;
|
||||||
|
|
||||||
|
/* Copy the original name into the buffer */
|
||||||
|
memcpy (DepName, Name, NameLen);
|
||||||
|
DepName[NameLen] = '+';
|
||||||
|
|
||||||
|
/* Define the labels */
|
||||||
|
for (Offs = 1; Offs < Count; ++Offs) {
|
||||||
|
sprintf (DepOffs, "%u", Offs);
|
||||||
|
AddLabel (Addr + Offs, atDepLabel, DepName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the name buffer */
|
||||||
|
xfree (DepName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int HaveLabel (unsigned Addr)
|
int HaveLabel (unsigned Addr)
|
||||||
/* Check if there is a label for the given address */
|
/* Check if there is a label for the given address */
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000 Ullrich von Bassewitz */
|
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Römerstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -51,11 +51,12 @@ typedef enum attr_t {
|
|||||||
atCode = 0x01,
|
atCode = 0x01,
|
||||||
atIllegal = 0x02,
|
atIllegal = 0x02,
|
||||||
atByteTab = 0x03, /* Same as illegal */
|
atByteTab = 0x03, /* Same as illegal */
|
||||||
atWordTab = 0x04,
|
atDByteTab = 0x04,
|
||||||
atDWordTab = 0x05,
|
atWordTab = 0x05,
|
||||||
atAddrTab = 0x06,
|
atDWordTab = 0x06,
|
||||||
atRtsTab = 0x07,
|
atAddrTab = 0x07,
|
||||||
atTextTab = 0x08,
|
atRtsTab = 0x08,
|
||||||
|
atTextTab = 0x09,
|
||||||
|
|
||||||
/* Label flags */
|
/* Label flags */
|
||||||
atNoLabel = 0x00, /* No label for this address */
|
atNoLabel = 0x00, /* No label for this address */
|
||||||
@ -89,6 +90,11 @@ const char* MakeLabelName (unsigned Addr);
|
|||||||
void AddLabel (unsigned Addr, attr_t Attr, const char* Name);
|
void AddLabel (unsigned Addr, attr_t Attr, const char* Name);
|
||||||
/* Add a label */
|
/* Add a label */
|
||||||
|
|
||||||
|
void AddExtLabelRange (unsigned Addr, const char* Name, unsigned Count);
|
||||||
|
/* Add an external label for a range. The first entry gets the label "Name"
|
||||||
|
* while the others get "Name+offs".
|
||||||
|
*/
|
||||||
|
|
||||||
int HaveLabel (unsigned Addr);
|
int HaveLabel (unsigned Addr);
|
||||||
/* Check if there is a label for the given address */
|
/* Check if there is a label for the given address */
|
||||||
|
|
||||||
|
@ -139,6 +139,16 @@ unsigned char GetCodeByte (unsigned Addr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned GetCodeDByte (unsigned Addr)
|
||||||
|
/* Get a dbyte from the given address */
|
||||||
|
{
|
||||||
|
unsigned Lo = GetCodeByte (Addr);
|
||||||
|
unsigned Hi = GetCodeByte (Addr+1);
|
||||||
|
return (Lo <<8) | Hi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned GetCodeWord (unsigned Addr)
|
unsigned GetCodeWord (unsigned Addr)
|
||||||
/* Get a word from the given address */
|
/* Get a word from the given address */
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,9 @@ void LoadCode (void);
|
|||||||
unsigned char GetCodeByte (unsigned Addr);
|
unsigned char GetCodeByte (unsigned Addr);
|
||||||
/* Get a byte from the given address */
|
/* Get a byte from the given address */
|
||||||
|
|
||||||
|
unsigned GetCodeDByte (unsigned Addr);
|
||||||
|
/* Get a dbyte from the given address */
|
||||||
|
|
||||||
unsigned GetCodeWord (unsigned Addr);
|
unsigned GetCodeWord (unsigned Addr);
|
||||||
/* Get a word from the given address */
|
/* Get a word from the given address */
|
||||||
|
|
||||||
|
@ -128,6 +128,15 @@ unsigned ByteTable (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned DByteTable (void)
|
||||||
|
/* Output a table of dbytes */
|
||||||
|
{
|
||||||
|
/* Call the low level function */
|
||||||
|
return DoTable (atDByteTab, 2, DataDByteLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned WordTable (void)
|
unsigned WordTable (void)
|
||||||
/* Output a table of words */
|
/* Output a table of words */
|
||||||
{
|
{
|
||||||
@ -154,7 +163,7 @@ unsigned AddrTable (void)
|
|||||||
/* Count how many bytes may be output. */
|
/* Count how many bytes may be output. */
|
||||||
unsigned Count = GetSpan (atAddrTab);
|
unsigned Count = GetSpan (atAddrTab);
|
||||||
|
|
||||||
/* Handle Count == 1 ### */
|
/* Handle Count == 1 */
|
||||||
if (Count == 1) {
|
if (Count == 1) {
|
||||||
ByteTable ();
|
ByteTable ();
|
||||||
}
|
}
|
||||||
@ -214,7 +223,10 @@ unsigned RtsTable (void)
|
|||||||
/* Count how many bytes may be output. */
|
/* Count how many bytes may be output. */
|
||||||
unsigned Count = GetSpan (atRtsTab);
|
unsigned Count = GetSpan (atRtsTab);
|
||||||
|
|
||||||
/* Need to handle Count == 1 here!!! ### */
|
/* Handle Count == 1 */
|
||||||
|
if (Count == 1) {
|
||||||
|
ByteTable ();
|
||||||
|
}
|
||||||
|
|
||||||
/* Make the given number even */
|
/* Make the given number even */
|
||||||
Count &= ~1U;
|
Count &= ~1U;
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
unsigned ByteTable (void);
|
unsigned ByteTable (void);
|
||||||
/* Output a table of bytes */
|
/* Output a table of bytes */
|
||||||
|
|
||||||
|
unsigned DByteTable (void);
|
||||||
|
/* Output a table of dbytes */
|
||||||
|
|
||||||
unsigned WordTable (void);
|
unsigned WordTable (void);
|
||||||
/* Output a table of words */
|
/* Output a table of words */
|
||||||
|
|
||||||
|
@ -60,6 +60,9 @@ long StartAddr = -1; /* Start/load address of the program */
|
|||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
unsigned char Pass = 0; /* Disassembler pass */
|
unsigned char Pass = 0; /* Disassembler pass */
|
||||||
|
|
||||||
|
/* Comments */
|
||||||
|
unsigned char Comments = 0; /* Add which comments to the output? */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
unsigned PageLength = 0; /* Length of a listing page */
|
unsigned PageLength = 0; /* Length of a listing page */
|
||||||
unsigned MIndent = 9; /* Mnemonic indent */
|
unsigned MIndent = 9; /* Mnemonic indent */
|
||||||
|
@ -62,6 +62,11 @@ extern long StartAddr; /* Start/load address of the program */
|
|||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
extern unsigned char Pass; /* Disassembler pass */
|
extern unsigned char Pass; /* Disassembler pass */
|
||||||
|
|
||||||
|
/* Comments */
|
||||||
|
#define MIN_COMMENTS 0
|
||||||
|
#define MAX_COMMENTS 4
|
||||||
|
extern unsigned char Comments; /* Add which comments to the output? */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
#define MIN_PAGE_LEN 32
|
#define MIN_PAGE_LEN 32
|
||||||
#define MAX_PAGE_LEN 127
|
#define MAX_PAGE_LEN 127
|
||||||
|
@ -67,6 +67,7 @@ static void GlobalSection (void)
|
|||||||
/* Parse a global section */
|
/* Parse a global section */
|
||||||
{
|
{
|
||||||
static const IdentTok GlobalDefs[] = {
|
static const IdentTok GlobalDefs[] = {
|
||||||
|
{ "COMMENTS", INFOTOK_COMMENTS },
|
||||||
{ "CPU", INFOTOK_CPU },
|
{ "CPU", INFOTOK_CPU },
|
||||||
{ "INPUTNAME", INFOTOK_INPUTNAME },
|
{ "INPUTNAME", INFOTOK_INPUTNAME },
|
||||||
{ "OUTPUTNAME", INFOTOK_OUTPUTNAME },
|
{ "OUTPUTNAME", INFOTOK_OUTPUTNAME },
|
||||||
@ -89,6 +90,14 @@ static void GlobalSection (void)
|
|||||||
/* Look at the token */
|
/* Look at the token */
|
||||||
switch (InfoTok) {
|
switch (InfoTok) {
|
||||||
|
|
||||||
|
case INFOTOK_COMMENTS:
|
||||||
|
InfoNextTok ();
|
||||||
|
InfoAssureInt ();
|
||||||
|
InfoRangeCheck (MIN_COMMENTS, MAX_COMMENTS);
|
||||||
|
Comments = InfoIVal;
|
||||||
|
InfoNextTok ();
|
||||||
|
break;
|
||||||
|
|
||||||
case INFOTOK_CPU:
|
case INFOTOK_CPU:
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
InfoAssureStr ();
|
InfoAssureStr ();
|
||||||
@ -155,35 +164,39 @@ static void RangeSection (void)
|
|||||||
/* Parse a range section */
|
/* Parse a range section */
|
||||||
{
|
{
|
||||||
static const IdentTok RangeDefs[] = {
|
static const IdentTok RangeDefs[] = {
|
||||||
{ "START", INFOTOK_START },
|
|
||||||
{ "END", INFOTOK_END },
|
{ "END", INFOTOK_END },
|
||||||
{ "TYPE", INFOTOK_TYPE },
|
{ "NAME", INFOTOK_NAME },
|
||||||
|
{ "START", INFOTOK_START },
|
||||||
|
{ "TYPE", INFOTOK_TYPE },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const IdentTok TypeDefs[] = {
|
static const IdentTok TypeDefs[] = {
|
||||||
{ "CODE", INFOTOK_CODE },
|
{ "CODE", INFOTOK_CODE },
|
||||||
{ "BYTETABLE", INFOTOK_BYTETAB },
|
{ "BYTETABLE", INFOTOK_BYTETAB },
|
||||||
{ "WORDTABLE", INFOTOK_WORDTAB },
|
{ "DBYTETABLE", INFOTOK_DBYTETAB },
|
||||||
{ "DWORDTABLE", INFOTOK_DWORDTAB },
|
{ "WORDTABLE", INFOTOK_WORDTAB },
|
||||||
{ "ADDRTABLE", INFOTOK_ADDRTAB },
|
{ "DWORDTABLE", INFOTOK_DWORDTAB },
|
||||||
{ "RTSTABLE", INFOTOK_RTSTAB },
|
{ "ADDRTABLE", INFOTOK_ADDRTAB },
|
||||||
{ "TEXTTABLE", INFOTOK_TEXTTAB },
|
{ "RTSTABLE", INFOTOK_RTSTAB },
|
||||||
|
{ "TEXTTABLE", INFOTOK_TEXTTAB },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Which values did we get? */
|
/* Which values did we get? */
|
||||||
enum {
|
enum {
|
||||||
tNone = 0x00,
|
tNone = 0x00,
|
||||||
tStart = 0x01,
|
tStart = 0x01,
|
||||||
tEnd = 0x02,
|
tEnd = 0x02,
|
||||||
tType = 0x04,
|
tType = 0x04,
|
||||||
tAll = 0x07
|
tName = 0x08,
|
||||||
} Needed = tNone;
|
tNeeded = (tStart | tEnd | tType)
|
||||||
|
} Attributes = tNone;
|
||||||
|
|
||||||
/* Locals - initialize to avoid gcc warnings */
|
/* Locals - initialize to avoid gcc warnings */
|
||||||
unsigned Start = 0;
|
unsigned Start = 0;
|
||||||
unsigned End = 0;
|
unsigned End = 0;
|
||||||
unsigned char Type = 0;
|
unsigned char Type = 0;
|
||||||
|
char* Name = 0;
|
||||||
|
|
||||||
/* Skip the token */
|
/* Skip the token */
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
@ -200,21 +213,35 @@ static void RangeSection (void)
|
|||||||
/* Look at the token */
|
/* Look at the token */
|
||||||
switch (InfoTok) {
|
switch (InfoTok) {
|
||||||
|
|
||||||
case INFOTOK_START:
|
|
||||||
InfoNextTok ();
|
|
||||||
InfoAssureInt ();
|
|
||||||
InfoRangeCheck (0x0000, 0xFFFF);
|
|
||||||
Start = InfoIVal;
|
|
||||||
Needed |= tStart;
|
|
||||||
InfoNextTok ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INFOTOK_END:
|
case INFOTOK_END:
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
InfoAssureInt ();
|
InfoAssureInt ();
|
||||||
InfoRangeCheck (0x0000, 0xFFFF);
|
InfoRangeCheck (0x0000, 0xFFFF);
|
||||||
End = InfoIVal;
|
End = InfoIVal;
|
||||||
Needed |= tEnd;
|
Attributes |= tEnd;
|
||||||
|
InfoNextTok ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INFOTOK_NAME:
|
||||||
|
InfoNextTok ();
|
||||||
|
if (Name) {
|
||||||
|
InfoError ("Name already given");
|
||||||
|
}
|
||||||
|
InfoAssureStr ();
|
||||||
|
if (InfoSVal[0] == '\0') {
|
||||||
|
InfoError ("Name may not be empty");
|
||||||
|
}
|
||||||
|
Name = xstrdup (InfoSVal);
|
||||||
|
Attributes |= tName;
|
||||||
|
InfoNextTok ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INFOTOK_START:
|
||||||
|
InfoNextTok ();
|
||||||
|
InfoAssureInt ();
|
||||||
|
InfoRangeCheck (0x0000, 0xFFFF);
|
||||||
|
Start = InfoIVal;
|
||||||
|
Attributes |= tStart;
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -224,13 +251,14 @@ static void RangeSection (void)
|
|||||||
switch (InfoTok) {
|
switch (InfoTok) {
|
||||||
case INFOTOK_CODE: Type = atCode; break;
|
case INFOTOK_CODE: Type = atCode; break;
|
||||||
case INFOTOK_BYTETAB: Type = atByteTab; break;
|
case INFOTOK_BYTETAB: Type = atByteTab; break;
|
||||||
|
case INFOTOK_DBYTETAB: Type = atDByteTab; break;
|
||||||
case INFOTOK_WORDTAB: Type = atWordTab; break;
|
case INFOTOK_WORDTAB: Type = atWordTab; break;
|
||||||
case INFOTOK_DWORDTAB: Type = atDWordTab; break;
|
case INFOTOK_DWORDTAB: Type = atDWordTab; break;
|
||||||
case INFOTOK_ADDRTAB: Type = atAddrTab; break;
|
case INFOTOK_ADDRTAB: Type = atAddrTab; break;
|
||||||
case INFOTOK_RTSTAB: Type = atRtsTab; break;
|
case INFOTOK_RTSTAB: Type = atRtsTab; break;
|
||||||
case INFOTOK_TEXTTAB: Type = atTextTab; break;
|
case INFOTOK_TEXTTAB: Type = atTextTab; break;
|
||||||
}
|
}
|
||||||
Needed |= tType;
|
Attributes |= tType;
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -241,7 +269,7 @@ static void RangeSection (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Did we get all required values? */
|
/* Did we get all required values? */
|
||||||
if (Needed != tAll) {
|
if ((Attributes & tNeeded) != tNeeded) {
|
||||||
InfoError ("Required values missing from this section");
|
InfoError ("Required values missing from this section");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +281,14 @@ static void RangeSection (void)
|
|||||||
/* Set the range */
|
/* Set the range */
|
||||||
MarkRange (Start, End, Type);
|
MarkRange (Start, End, Type);
|
||||||
|
|
||||||
|
/* Do we have a label? */
|
||||||
|
if (Attributes & tName) {
|
||||||
|
/* Define a label for the table */
|
||||||
|
AddLabel (Start, atExtLabel, Name);
|
||||||
|
/* Delete the name */
|
||||||
|
xfree (Name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Consume the closing brace */
|
/* Consume the closing brace */
|
||||||
InfoConsumeRCurly ();
|
InfoConsumeRCurly ();
|
||||||
}
|
}
|
||||||
@ -347,31 +383,8 @@ static void LabelSection (void)
|
|||||||
InfoError ("Label for address $%04lX already defined", Value);
|
InfoError ("Label for address $%04lX already defined", Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define the label */
|
/* Define the label(s) */
|
||||||
AddLabel ((unsigned) Value, atExtLabel, Name);
|
AddExtLabelRange ((unsigned) Value, Name, Size);
|
||||||
|
|
||||||
/* Define dependent labels if necessary */
|
|
||||||
if (Size > 1) {
|
|
||||||
unsigned Offs;
|
|
||||||
|
|
||||||
/* Allocate memory for the dependent label names */
|
|
||||||
unsigned NameLen = strlen (Name);
|
|
||||||
char* DepName = xmalloc (NameLen + 7);
|
|
||||||
char* DepOffs = DepName + NameLen + 1;
|
|
||||||
|
|
||||||
/* Copy the original name into the buffer */
|
|
||||||
memcpy (DepName, Name, NameLen);
|
|
||||||
DepName[NameLen] = '+';
|
|
||||||
|
|
||||||
/* Define the labels */
|
|
||||||
for (Offs = 1; Offs < (unsigned) Size; ++Offs) {
|
|
||||||
sprintf (DepOffs, "%u", Offs);
|
|
||||||
AddLabel ((unsigned) Value+Offs, atDepLabel, DepName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the name buffer */
|
|
||||||
xfree (DepName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete the dynamically allocated memory for Name */
|
/* Delete the dynamically allocated memory for Name */
|
||||||
xfree (Name);
|
xfree (Name);
|
||||||
|
@ -82,6 +82,7 @@ static void Usage (void)
|
|||||||
" -V\t\t\tPrint the disassembler version\n"
|
" -V\t\t\tPrint the disassembler version\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Long options:\n"
|
"Long options:\n"
|
||||||
|
" --comments n\t\tSet the comment level for the output\n"
|
||||||
" --cpu type\t\tSet cpu type\n"
|
" --cpu type\t\tSet cpu type\n"
|
||||||
" --debug-info\t\tAdd debug info to object file\n"
|
" --debug-info\t\tAdd debug info to object file\n"
|
||||||
" --formfeeds\t\tAdd formfeeds to the output\n"
|
" --formfeeds\t\tAdd formfeeds to the output\n"
|
||||||
@ -103,13 +104,14 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
|
|||||||
{
|
{
|
||||||
unsigned long Val;
|
unsigned long Val;
|
||||||
int Converted;
|
int Converted;
|
||||||
|
char BoundsCheck;
|
||||||
|
|
||||||
/* Convert */
|
/* Convert */
|
||||||
if (*Number == '$') {
|
if (*Number == '$') {
|
||||||
++Number;
|
++Number;
|
||||||
Converted = sscanf (Number, "%lx", &Val);
|
Converted = sscanf (Number, "%lx%c", &Val, &BoundsCheck);
|
||||||
} else {
|
} else {
|
||||||
Converted = sscanf (Number, "%li", (long*)&Val);
|
Converted = sscanf (Number, "%li%c", (long*)&Val, &BoundsCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we do really have a number */
|
/* Check if we do really have a number */
|
||||||
@ -123,6 +125,24 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptComments (const char* Opt, const char* Arg)
|
||||||
|
/* Handle the --comments option */
|
||||||
|
{
|
||||||
|
/* Convert the argument to a number */
|
||||||
|
unsigned long Val = CvtNumber (Opt, Arg);
|
||||||
|
|
||||||
|
/* Check for a valid range */
|
||||||
|
if (Val > MAX_COMMENTS) {
|
||||||
|
Error ("Argument for %s outside valid range (%d-%d)",
|
||||||
|
Opt, MIN_COMMENTS, MAX_COMMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use the value */
|
||||||
|
Comments = (unsigned char) Val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
|
static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
|
||||||
/* Handle the --cpu option */
|
/* Handle the --cpu option */
|
||||||
{
|
{
|
||||||
@ -134,7 +154,7 @@ static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
|
|||||||
|
|
||||||
|
|
||||||
static void OptDebugInfo (const char* Opt attribute ((unused)),
|
static void OptDebugInfo (const char* Opt attribute ((unused)),
|
||||||
const char* Arg attribute ((unused)))
|
const char* Arg attribute ((unused)))
|
||||||
/* Add debug info to the object file */
|
/* Add debug info to the object file */
|
||||||
{
|
{
|
||||||
DebugInfo = 1;
|
DebugInfo = 1;
|
||||||
@ -258,6 +278,10 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
ByteTable ();
|
ByteTable ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case atDByteTab:
|
||||||
|
DByteTable ();
|
||||||
|
break;
|
||||||
|
|
||||||
case atWordTab:
|
case atWordTab:
|
||||||
WordTable ();
|
WordTable ();
|
||||||
break;
|
break;
|
||||||
@ -326,6 +350,7 @@ int main (int argc, char* argv [])
|
|||||||
{
|
{
|
||||||
/* Program long options */
|
/* Program long options */
|
||||||
static const LongOpt OptTab[] = {
|
static const LongOpt OptTab[] = {
|
||||||
|
{ "--comments", 1, OptComments },
|
||||||
{ "--cpu", 1, OptCPU },
|
{ "--cpu", 1, OptCPU },
|
||||||
{ "--debug-info", 0, OptDebugInfo },
|
{ "--debug-info", 0, OptDebugInfo },
|
||||||
{ "--formfeeds", 0, OptFormFeeds },
|
{ "--formfeeds", 0, OptFormFeeds },
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "print.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* da65 */
|
/* da65 */
|
||||||
@ -188,6 +187,27 @@ void DataByteLine (unsigned ByteCount)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DataDByteLine (unsigned ByteCount)
|
||||||
|
/* Output a line with dbytes */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
Indent (MIndent);
|
||||||
|
Output (".dbyte");
|
||||||
|
Indent (AIndent);
|
||||||
|
for (I = 0; I < ByteCount; I += 2) {
|
||||||
|
if (I > 0) {
|
||||||
|
Output (",$%04X", GetCodeDByte (PC+I));
|
||||||
|
} else {
|
||||||
|
Output ("$%04X", GetCodeDByte (PC+I));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LineComment (PC, ByteCount);
|
||||||
|
LineFeed ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DataWordLine (unsigned ByteCount)
|
void DataWordLine (unsigned ByteCount)
|
||||||
/* Output a line with words */
|
/* Output a line with words */
|
||||||
{
|
{
|
||||||
@ -233,7 +253,7 @@ void DataDWordLine (unsigned ByteCount)
|
|||||||
void SeparatorLine (void)
|
void SeparatorLine (void)
|
||||||
/* Print a separator line */
|
/* Print a separator line */
|
||||||
{
|
{
|
||||||
if (Pass == PassCount && Verbosity >= 1) {
|
if (Pass == PassCount && Comments >= 1) {
|
||||||
Output ("; ----------------------------------------------------------------------------");
|
Output ("; ----------------------------------------------------------------------------");
|
||||||
LineFeed ();
|
LineFeed ();
|
||||||
}
|
}
|
||||||
@ -246,14 +266,14 @@ void LineComment (unsigned PC, unsigned Count)
|
|||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
if (Pass == PassCount && Verbosity >= 2) {
|
if (Pass == PassCount && Comments >= 2) {
|
||||||
Indent (CIndent);
|
Indent (CIndent);
|
||||||
Output ("; %04X", PC);
|
Output ("; %04X", PC);
|
||||||
if (Verbosity >= 3) {
|
if (Comments >= 3) {
|
||||||
for (I = 0; I < Count; ++I) {
|
for (I = 0; I < Count; ++I) {
|
||||||
Output (" %02X", CodeBuf [PC+I]);
|
Output (" %02X", CodeBuf [PC+I]);
|
||||||
}
|
}
|
||||||
if (Verbosity >= 4) {
|
if (Comments >= 4) {
|
||||||
Indent (TIndent);
|
Indent (TIndent);
|
||||||
for (I = 0; I < Count; ++I) {
|
for (I = 0; I < Count; ++I) {
|
||||||
unsigned char C = CodeBuf [PC+I];
|
unsigned char C = CodeBuf [PC+I];
|
||||||
|
@ -73,6 +73,9 @@ void OneDataByte (void);
|
|||||||
void DataByteLine (unsigned ByteCount);
|
void DataByteLine (unsigned ByteCount);
|
||||||
/* Output a line with bytes */
|
/* Output a line with bytes */
|
||||||
|
|
||||||
|
void DataDByteLine (unsigned ByteCount);
|
||||||
|
/* Output a line with dbytes */
|
||||||
|
|
||||||
void DataWordLine (unsigned ByteCount);
|
void DataWordLine (unsigned ByteCount);
|
||||||
/* Output a line with words */
|
/* Output a line with words */
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ typedef enum token_t {
|
|||||||
INFOTOK_LABEL,
|
INFOTOK_LABEL,
|
||||||
|
|
||||||
/* Global section */
|
/* Global section */
|
||||||
|
INFOTOK_COMMENTS,
|
||||||
INFOTOK_CPU,
|
INFOTOK_CPU,
|
||||||
INFOTOK_INPUTNAME,
|
INFOTOK_INPUTNAME,
|
||||||
INFOTOK_OUTPUTNAME,
|
INFOTOK_OUTPUTNAME,
|
||||||
@ -77,7 +78,8 @@ typedef enum token_t {
|
|||||||
INFOTOK_TYPE,
|
INFOTOK_TYPE,
|
||||||
|
|
||||||
INFOTOK_CODE,
|
INFOTOK_CODE,
|
||||||
INFOTOK_BYTETAB,
|
INFOTOK_BYTETAB,
|
||||||
|
INFOTOK_DBYTETAB,
|
||||||
INFOTOK_WORDTAB,
|
INFOTOK_WORDTAB,
|
||||||
INFOTOK_DWORDTAB,
|
INFOTOK_DWORDTAB,
|
||||||
INFOTOK_ADDRTAB,
|
INFOTOK_ADDRTAB,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user