mirror of
https://github.com/cc65/cc65.git
synced 2025-08-13 08:25:28 +00:00
Added text tables
git-svn-id: svn://svn.cc65.org/cc65/trunk@941 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -55,6 +55,7 @@ typedef enum attr_t {
|
|||||||
atDWordTab = 0x05,
|
atDWordTab = 0x05,
|
||||||
atAddrTab = 0x06,
|
atAddrTab = 0x06,
|
||||||
atRtsTab = 0x07,
|
atRtsTab = 0x07,
|
||||||
|
atTextTab = 0x08,
|
||||||
|
|
||||||
/* Label flags */
|
/* Label flags */
|
||||||
atNoLabel = 0x00, /* No label for this address */
|
atNoLabel = 0x00, /* No label for this address */
|
||||||
|
@@ -153,6 +153,7 @@ static void RangeSection (void)
|
|||||||
{ "DWORDTABLE", CFGTOK_DWORDTAB },
|
{ "DWORDTABLE", CFGTOK_DWORDTAB },
|
||||||
{ "ADDRTABLE", CFGTOK_ADDRTAB },
|
{ "ADDRTABLE", CFGTOK_ADDRTAB },
|
||||||
{ "RTSTABLE", CFGTOK_RTSTAB },
|
{ "RTSTABLE", CFGTOK_RTSTAB },
|
||||||
|
{ "TEXTTABLE", CFGTOK_TEXTTAB },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -213,6 +214,7 @@ static void RangeSection (void)
|
|||||||
case CFGTOK_DWORDTAB: Type = atDWordTab; break;
|
case CFGTOK_DWORDTAB: Type = atDWordTab; break;
|
||||||
case CFGTOK_ADDRTAB: Type = atAddrTab; break;
|
case CFGTOK_ADDRTAB: Type = atAddrTab; break;
|
||||||
case CFGTOK_RTSTAB: Type = atRtsTab; break;
|
case CFGTOK_RTSTAB: Type = atRtsTab; break;
|
||||||
|
case CFGTOK_TEXTTAB: Type = atTextTab; break;
|
||||||
}
|
}
|
||||||
Needed |= tType;
|
Needed |= tType;
|
||||||
CfgNextTok ();
|
CfgNextTok ();
|
||||||
|
@@ -263,3 +263,82 @@ unsigned RtsTable (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned TextTable (void)
|
||||||
|
/* Output a table of text messages */
|
||||||
|
{
|
||||||
|
/* Count how many bytes may be output. */
|
||||||
|
unsigned ByteCount = GetSpan (atTextTab);
|
||||||
|
|
||||||
|
/* Output as many data bytes lines as needed. */
|
||||||
|
unsigned BytesLeft = ByteCount;
|
||||||
|
while (BytesLeft > 0) {
|
||||||
|
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Count the number of characters that can be output as such */
|
||||||
|
unsigned Count = 0;
|
||||||
|
while (Count < BytesLeft && Count < BytesPerLine*4-1) {
|
||||||
|
unsigned char C = GetCodeByte (PC + Count);
|
||||||
|
if (C >= 0x20 && C <= 0x7E && C != '\"') {
|
||||||
|
++Count;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we have text, output it */
|
||||||
|
if (Count > 0) {
|
||||||
|
unsigned CBytes;
|
||||||
|
Indent (MIndent);
|
||||||
|
Output (".text");
|
||||||
|
Indent (AIndent);
|
||||||
|
Output ("\"");
|
||||||
|
for (I = 0; I < Count; ++I) {
|
||||||
|
Output ("%c", GetCodeByte (PC+I));
|
||||||
|
}
|
||||||
|
Output ("\"");
|
||||||
|
CBytes = Count;
|
||||||
|
while (CBytes > 0) {
|
||||||
|
unsigned Chunk = CBytes;
|
||||||
|
if (Chunk > BytesPerLine) {
|
||||||
|
Chunk = BytesPerLine;
|
||||||
|
}
|
||||||
|
LineComment (PC, Chunk);
|
||||||
|
LineFeed ();
|
||||||
|
CBytes -= Chunk;
|
||||||
|
PC += Chunk;
|
||||||
|
}
|
||||||
|
BytesLeft -= Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Count the number of bytes that must be output as bytes */
|
||||||
|
Count = 0;
|
||||||
|
while (Count < BytesLeft && Count < BytesPerLine) {
|
||||||
|
unsigned char C = GetCodeByte (PC + Count);
|
||||||
|
if (C < 0x20 || C > 0x7E || C == '\"') {
|
||||||
|
++Count;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we have raw output bytes, print them */
|
||||||
|
if (Count > 0) {
|
||||||
|
DataByteLine (Count);
|
||||||
|
PC += Count;
|
||||||
|
BytesLeft -= Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the next line is not a byte table line, add a separator */
|
||||||
|
if (CodeLeft() && GetStyleAttr (PC) != atTextTab) {
|
||||||
|
SeparatorLine ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of bytes output */
|
||||||
|
return ByteCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -58,7 +58,10 @@ unsigned AddrTable (void);
|
|||||||
|
|
||||||
unsigned RtsTable (void);
|
unsigned RtsTable (void);
|
||||||
/* Output a table of RTS addresses (address - 1) */
|
/* Output a table of RTS addresses (address - 1) */
|
||||||
|
|
||||||
|
unsigned TextTable (void);
|
||||||
|
/* Output a table of text messages */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of data.h */
|
/* End of data.h */
|
||||||
|
@@ -267,6 +267,10 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
RtsTable ();
|
RtsTable ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case atTextTab:
|
||||||
|
TextTable ();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DataByteLine (1);
|
DataByteLine (1);
|
||||||
++PC;
|
++PC;
|
||||||
|
@@ -138,9 +138,9 @@ void Indent (unsigned N)
|
|||||||
void LineFeed (void)
|
void LineFeed (void)
|
||||||
/* Add a linefeed to the output file */
|
/* Add a linefeed to the output file */
|
||||||
{
|
{
|
||||||
if (Pass == PassCount && PageLength > 0) {
|
if (Pass == PassCount) {
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
if (++Line >= PageLength) {
|
if (PageLength > 0 && ++Line >= PageLength) {
|
||||||
if (FormFeeds) {
|
if (FormFeeds) {
|
||||||
fputc ('\f', F);
|
fputc ('\f', F);
|
||||||
}
|
}
|
||||||
|
@@ -81,6 +81,7 @@ typedef enum token_t {
|
|||||||
CFGTOK_DWORDTAB,
|
CFGTOK_DWORDTAB,
|
||||||
CFGTOK_ADDRTAB,
|
CFGTOK_ADDRTAB,
|
||||||
CFGTOK_RTSTAB,
|
CFGTOK_RTSTAB,
|
||||||
|
CFGTOK_TEXTTAB,
|
||||||
|
|
||||||
/* Label section */
|
/* Label section */
|
||||||
CFGTOK_NAME,
|
CFGTOK_NAME,
|
||||||
|
Reference in New Issue
Block a user