Added dword tables, char comments etc.
git-svn-id: svn://svn.cc65.org/cc65/trunk@340 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -51,8 +51,9 @@ enum attr_t {
|
|||||||
atIllegal = 0x02,
|
atIllegal = 0x02,
|
||||||
atByteTab = 0x03, /* Same as illegal */
|
atByteTab = 0x03, /* Same as illegal */
|
||||||
atWordTab = 0x04,
|
atWordTab = 0x04,
|
||||||
atAddrTab = 0x05,
|
atDWordTab = 0x05,
|
||||||
atRtsTab = 0x06,
|
atAddrTab = 0x06,
|
||||||
|
atRtsTab = 0x07,
|
||||||
|
|
||||||
atStyleMask = 0x0F /* Output style */
|
atStyleMask = 0x0F /* Output style */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ void LoadCode (const char* Name, unsigned long StartAddress)
|
|||||||
Error ("Error reading from `%s': %s", Name, strerror (errno));
|
Error ("Error reading from `%s': %s", Name, strerror (errno));
|
||||||
}
|
}
|
||||||
if (Count == 0) {
|
if (Count == 0) {
|
||||||
Error ("File `%s' contains no data", Name);
|
Error ("File `%s' contains no data", Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the buffer variables */
|
/* Set the buffer variables */
|
||||||
@@ -118,18 +118,36 @@ unsigned GetCodeWord (unsigned Addr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long GetCodeDWord (unsigned Addr)
|
||||||
|
/* Get a dword from the given address */
|
||||||
|
{
|
||||||
|
unsigned long Lo = GetCodeWord (Addr);
|
||||||
|
unsigned long Hi = GetCodeWord (Addr+2);
|
||||||
|
return Lo | (Hi << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned GetRemainingBytes (void)
|
unsigned GetRemainingBytes (void)
|
||||||
/* Return the number of remaining code bytes */
|
/* Return the number of remaining code bytes */
|
||||||
{
|
{
|
||||||
if (CodeEnd >= PC) {
|
if (CodeEnd >= PC) {
|
||||||
return (CodeEnd - PC + 1);
|
return (CodeEnd - PC + 1);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CodeLeft (void)
|
||||||
|
/* Return true if there are code bytes left */
|
||||||
|
{
|
||||||
|
return (PC <= CodeEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ResetCode (void)
|
void ResetCode (void)
|
||||||
/* Reset the code input to start over for the next pass */
|
/* Reset the code input to start over for the next pass */
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,9 +66,15 @@ unsigned char GetCodeByte (unsigned Addr);
|
|||||||
unsigned GetCodeWord (unsigned Addr);
|
unsigned GetCodeWord (unsigned Addr);
|
||||||
/* Get a word from the given address */
|
/* Get a word from the given address */
|
||||||
|
|
||||||
|
unsigned long GetCodeDWord (unsigned Addr);
|
||||||
|
/* Get a dword from the given address */
|
||||||
|
|
||||||
unsigned GetRemainingBytes (void);
|
unsigned GetRemainingBytes (void);
|
||||||
/* Return the number of remaining code bytes */
|
/* Return the number of remaining code bytes */
|
||||||
|
|
||||||
|
int CodeLeft (void);
|
||||||
|
/* Return true if there are code bytes left */
|
||||||
|
|
||||||
void ResetCode (void);
|
void ResetCode (void);
|
||||||
/* Reset the code input to start over for the next pass */
|
/* Reset the code input to start over for the next pass */
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ static void RangeSection (void)
|
|||||||
{ "CODE", CFGTOK_CODE },
|
{ "CODE", CFGTOK_CODE },
|
||||||
{ "BYTETABLE", CFGTOK_BYTETAB },
|
{ "BYTETABLE", CFGTOK_BYTETAB },
|
||||||
{ "WORDTABLE", CFGTOK_WORDTAB },
|
{ "WORDTABLE", CFGTOK_WORDTAB },
|
||||||
|
{ "DWORDTABLE", CFGTOK_DWORDTAB },
|
||||||
{ "ADDRTABLE", CFGTOK_ADDRTAB },
|
{ "ADDRTABLE", CFGTOK_ADDRTAB },
|
||||||
{ "RTSTABLE", CFGTOK_RTSTAB },
|
{ "RTSTABLE", CFGTOK_RTSTAB },
|
||||||
};
|
};
|
||||||
@@ -197,6 +198,7 @@ static void RangeSection (void)
|
|||||||
case CFGTOK_CODE: Type = atCode; break;
|
case CFGTOK_CODE: Type = atCode; break;
|
||||||
case CFGTOK_BYTETAB: Type = atByteTab; break;
|
case CFGTOK_BYTETAB: Type = atByteTab; break;
|
||||||
case CFGTOK_WORDTAB: Type = atWordTab; break;
|
case CFGTOK_WORDTAB: Type = atWordTab; 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;
|
||||||
}
|
}
|
||||||
|
|||||||
161
src/da65/data.c
161
src/da65/data.c
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
/* da65 */
|
/* da65 */
|
||||||
#include "attrtab.h"
|
#include "attrtab.h"
|
||||||
#include "code.h"
|
#include "code.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
@@ -49,108 +49,110 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ByteTable (unsigned RemainingBytes)
|
static unsigned GetSpan (attr_t Style)
|
||||||
|
/* Get the number of bytes for a given style */
|
||||||
|
{
|
||||||
|
/* Get the number of bytes still available */
|
||||||
|
unsigned RemainingBytes = GetRemainingBytes ();
|
||||||
|
|
||||||
|
/* Count how many bytes are available. This number is limited by the
|
||||||
|
* number of remaining bytes, a label, or the end of the given Style
|
||||||
|
* attribute.
|
||||||
|
*/
|
||||||
|
unsigned Count = 1;
|
||||||
|
while (Count < RemainingBytes) {
|
||||||
|
if (HaveLabel(PC+Count) || GetStyle (PC+Count) != Style) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of bytes */
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned DoTable (attr_t Style, unsigned MemberSize, void (*TableFunc) (unsigned))
|
||||||
/* Output a table of bytes */
|
/* Output a table of bytes */
|
||||||
{
|
{
|
||||||
/* Count how many bytes may be output. This number is limited by the
|
unsigned BytesLeft;
|
||||||
* number of remaining bytes, a label, or the end of the ByteTable
|
|
||||||
* attribute.
|
/* Count how many bytes may be output. */
|
||||||
*/
|
unsigned Count = GetSpan (Style);
|
||||||
unsigned Count = 1;
|
|
||||||
while (Count < RemainingBytes) {
|
/* Make Count an even number of multiples of MemberSize */
|
||||||
if (HaveLabel(PC+Count) || GetStyle (PC+Count) != atByteTab) {
|
Count &= ~(MemberSize-1);
|
||||||
break;
|
|
||||||
}
|
|
||||||
++Count;
|
|
||||||
}
|
|
||||||
RemainingBytes -= Count;
|
|
||||||
|
|
||||||
/* Output as many data bytes lines as needed */
|
/* Output as many data bytes lines as needed */
|
||||||
while (Count > 0) {
|
BytesLeft = Count;
|
||||||
|
while (BytesLeft > 0) {
|
||||||
|
|
||||||
/* Calculate the number of bytes for the next line */
|
/* Calculate the number of bytes for the next line */
|
||||||
unsigned Chunk = (Count > BytesPerLine)? BytesPerLine : Count;
|
unsigned Chunk = (BytesLeft > BytesPerLine)? BytesPerLine : BytesLeft;
|
||||||
|
|
||||||
/* Output a line with these bytes */
|
/* Output a line with these bytes */
|
||||||
DataByteLine (Chunk);
|
TableFunc (Chunk);
|
||||||
|
|
||||||
/* Next line */
|
/* Next line */
|
||||||
Count -= Chunk;
|
BytesLeft -= Chunk;
|
||||||
PC += Chunk;
|
PC += Chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the next line is not a byte table line, add a separator */
|
/* If the next line is not the same style, add a separator */
|
||||||
if (RemainingBytes > 0 && GetStyle (PC) != atByteTab) {
|
if (CodeLeft() && GetStyle (PC) != Style) {
|
||||||
SeparatorLine ();
|
SeparatorLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the number of bytes output */
|
||||||
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WordTable (unsigned RemainingBytes)
|
unsigned ByteTable (void)
|
||||||
|
/* Output a table of bytes */
|
||||||
|
{
|
||||||
|
/* Call the low level function */
|
||||||
|
return DoTable (atByteTab, 1, DataByteLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned WordTable (void)
|
||||||
/* Output a table of words */
|
/* Output a table of words */
|
||||||
{
|
{
|
||||||
/* Count how many bytes may be output. This number is limited by the
|
/* Call the low level function */
|
||||||
* number of remaining bytes, a label, or the end of the WordTable
|
return DoTable (atWordTab, 2, DataWordLine);
|
||||||
* attribute.
|
|
||||||
*/
|
|
||||||
unsigned Count = 1;
|
|
||||||
while (Count < RemainingBytes) {
|
|
||||||
if (HaveLabel(PC+Count) || GetStyle (PC+Count) != atWordTab) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++Count;
|
|
||||||
}
|
|
||||||
RemainingBytes -= Count;
|
|
||||||
|
|
||||||
/* Make the given number even */
|
|
||||||
Count &= ~1U;
|
|
||||||
|
|
||||||
/* Output as many data word lines as needed */
|
|
||||||
while (Count > 0) {
|
|
||||||
|
|
||||||
/* Calculate the number of bytes for the next line */
|
|
||||||
unsigned Chunk = (Count > BytesPerLine)? BytesPerLine : Count;
|
|
||||||
|
|
||||||
/* Output a line with these bytes */
|
|
||||||
DataWordLine (Chunk);
|
|
||||||
|
|
||||||
/* Next line */
|
|
||||||
PC += Chunk;
|
|
||||||
Count -= Chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the next line is not a byte table line, add a separator */
|
|
||||||
if (RemainingBytes > 0 && GetStyle (PC) != atWordTab) {
|
|
||||||
SeparatorLine ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddrTable (unsigned RemainingBytes)
|
unsigned DWordTable (void)
|
||||||
|
/* Output a table of double words */
|
||||||
|
{
|
||||||
|
/* Call the low level function */
|
||||||
|
return DoTable (atDWordTab, 4, DataDWordLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned AddrTable (void)
|
||||||
/* Output a table of addresses */
|
/* Output a table of addresses */
|
||||||
{
|
{
|
||||||
/* Count how many bytes may be output. This number is limited by the
|
unsigned BytesLeft;
|
||||||
* number of remaining bytes, a label, or the end of the WordTable
|
|
||||||
* attribute.
|
/* Count how many bytes may be output. */
|
||||||
*/
|
unsigned Count = GetSpan (atAddrTab);
|
||||||
unsigned Count = 1;
|
|
||||||
while (Count < RemainingBytes) {
|
|
||||||
if (HaveLabel(PC+Count) || GetStyle (PC+Count) != atAddrTab) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++Count;
|
|
||||||
}
|
|
||||||
RemainingBytes -= Count;
|
|
||||||
|
|
||||||
/* Make the given number even */
|
/* Make the given number even */
|
||||||
Count &= ~1U;
|
Count &= ~1U;
|
||||||
|
|
||||||
/* Output as many data bytes lines as needed. For addresses, each line
|
/* Output as many data bytes lines as needed. For addresses, each line
|
||||||
* will hold just one address.
|
* will hold just one address.
|
||||||
*/
|
*/
|
||||||
while (Count > 0) {
|
BytesLeft = Count;
|
||||||
|
while (BytesLeft > 0) {
|
||||||
|
|
||||||
/* Get the address */
|
/* Get the address */
|
||||||
unsigned Addr = GetCodeWord (PC);
|
unsigned Addr = GetCodeWord (PC);
|
||||||
@@ -158,13 +160,13 @@ void AddrTable (unsigned RemainingBytes)
|
|||||||
/* In pass 1, define a label, in pass 2 output the line */
|
/* In pass 1, define a label, in pass 2 output the line */
|
||||||
if (Pass == 1) {
|
if (Pass == 1) {
|
||||||
if (!HaveLabel (Addr)) {
|
if (!HaveLabel (Addr)) {
|
||||||
AddLabel (Addr, MakeLabelName (Addr));
|
AddLabel (Addr, MakeLabelName (Addr));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const char* Label = GetLabel (Addr);
|
const char* Label = GetLabel (Addr);
|
||||||
if (Label == 0) {
|
if (Label == 0) {
|
||||||
/* OOPS! Should not happen */
|
/* OOPS! Should not happen */
|
||||||
Internal ("OOPS - Label for address %04X disappeard!", Addr);
|
Internal ("OOPS - Label for address %04X disappeard!", Addr);
|
||||||
}
|
}
|
||||||
Indent (MIndent);
|
Indent (MIndent);
|
||||||
Output (".word");
|
Output (".word");
|
||||||
@@ -175,14 +177,17 @@ void AddrTable (unsigned RemainingBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Next line */
|
/* Next line */
|
||||||
PC += 2;
|
PC += 2;
|
||||||
Count -= 2;
|
BytesLeft -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the next line is not a byte table line, add a separator */
|
/* If the next line is not a byte table line, add a separator */
|
||||||
if (RemainingBytes > 0 && GetStyle (PC) != atAddrTab) {
|
if (CodeLeft() && GetStyle (PC) != atAddrTab) {
|
||||||
SeparatorLine ();
|
SeparatorLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the number of bytes output */
|
||||||
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ByteTable (unsigned RemainingBytes);
|
unsigned ByteTable (void);
|
||||||
/* Output a table of bytes */
|
/* Output a table of bytes */
|
||||||
|
|
||||||
void WordTable (unsigned RemainingBytes);
|
unsigned WordTable (void);
|
||||||
/* Output a table of words */
|
/* Output a table of words */
|
||||||
|
|
||||||
void AddrTable (unsigned RemainingBytes);
|
unsigned DWordTable (void);
|
||||||
|
/* Output a table of double words */
|
||||||
|
|
||||||
|
unsigned AddrTable (void);
|
||||||
/* Output a table of addresses */
|
/* Output a table of addresses */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,15 +54,17 @@ const char CfgExt[] = ".cfg"; /* Config file extension */
|
|||||||
/* Flags and other command line stuff */
|
/* Flags and other command line stuff */
|
||||||
unsigned char Verbosity = 4; /* Verbosity of the output file */
|
unsigned char Verbosity = 4; /* Verbosity of the output file */
|
||||||
unsigned char FormFeeds = 0; /* Add form feeds to the output? */
|
unsigned char FormFeeds = 0; /* Add form feeds to the output? */
|
||||||
|
unsigned char PassCount = 2; /* How many passed do we do? */
|
||||||
|
|
||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
unsigned Pass = 0; /* Disassembler pass */
|
unsigned char Pass = 0; /* Disassembler pass */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
int PageLength = -1; /* Length of a listing page */
|
int PageLength = -1; /* Length of a listing page */
|
||||||
unsigned MIndent = 9; /* Mnemonic indent */
|
unsigned MIndent = 9; /* Mnemonic indent */
|
||||||
unsigned AIndent = 17; /* Argument indent */
|
unsigned AIndent = 17; /* Argument indent */
|
||||||
unsigned CIndent = 49; /* Comment indent */
|
unsigned CIndent = 49; /* Comment indent */
|
||||||
|
unsigned TIndent = 81; /* Text bytes indent */
|
||||||
unsigned BytesPerLine = 8; /* Max. number of data bytes per line */
|
unsigned BytesPerLine = 8; /* Max. number of data bytes per line */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ extern const char CfgExt[]; /* Config file extension */
|
|||||||
/* Flags and other command line stuff */
|
/* Flags and other command line stuff */
|
||||||
extern unsigned char Verbosity; /* Verbosity of the output file */
|
extern unsigned char Verbosity; /* Verbosity of the output file */
|
||||||
extern unsigned char FormFeeds; /* Add form feeds to the output? */
|
extern unsigned char FormFeeds; /* Add form feeds to the output? */
|
||||||
|
extern unsigned char PassCount; /* How many passed do we do? */
|
||||||
|
|
||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
extern unsigned Pass; /* Disassembler pass */
|
extern unsigned char Pass; /* Disassembler pass */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
#define MIN_PAGE_LEN 32
|
#define MIN_PAGE_LEN 32
|
||||||
@@ -66,6 +67,7 @@ extern int PageLength; /* Length of a listing page */
|
|||||||
extern unsigned MIndent; /* Mnemonic indent */
|
extern unsigned MIndent; /* Mnemonic indent */
|
||||||
extern unsigned AIndent; /* Argument indent */
|
extern unsigned AIndent; /* Argument indent */
|
||||||
extern unsigned CIndent; /* Comment indent */
|
extern unsigned CIndent; /* Comment indent */
|
||||||
|
extern unsigned TIndent; /* Text bytes indent */
|
||||||
extern unsigned BytesPerLine; /* Max. number of data bytes per line */
|
extern unsigned BytesPerLine; /* Max. number of data bytes per line */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -211,15 +211,19 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case atByteTab:
|
case atByteTab:
|
||||||
ByteTable (RemainingBytes);
|
ByteTable ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case atWordTab:
|
case atWordTab:
|
||||||
WordTable (RemainingBytes);
|
WordTable ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case atDWordTab:
|
||||||
|
DWordTable ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case atAddrTab:
|
case atAddrTab:
|
||||||
AddrTable (RemainingBytes);
|
AddrTable ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
@@ -110,7 +111,7 @@ void CloseOutput (void)
|
|||||||
void Output (const char* Format, ...)
|
void Output (const char* Format, ...)
|
||||||
/* Write to the output file */
|
/* Write to the output file */
|
||||||
{
|
{
|
||||||
if (Pass > 1) {
|
if (Pass == PassCount) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, Format);
|
va_start (ap, Format);
|
||||||
Col += vfprintf (F, Format, ap);
|
Col += vfprintf (F, Format, ap);
|
||||||
@@ -123,7 +124,7 @@ void Output (const char* Format, ...)
|
|||||||
void Indent (unsigned N)
|
void Indent (unsigned N)
|
||||||
/* Make sure the current line column is at position N (zero based) */
|
/* Make sure the current line column is at position N (zero based) */
|
||||||
{
|
{
|
||||||
if (Pass > 1) {
|
if (Pass == PassCount) {
|
||||||
while (Col < N) {
|
while (Col < N) {
|
||||||
fputc (' ', F);
|
fputc (' ', F);
|
||||||
++Col;
|
++Col;
|
||||||
@@ -136,7 +137,7 @@ 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 > 1) {
|
if (Pass == PassCount) {
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
if (++Line >= PageLength) {
|
if (++Line >= PageLength) {
|
||||||
if (FormFeeds) {
|
if (FormFeeds) {
|
||||||
@@ -156,48 +157,72 @@ void DefLabel (const char* Name)
|
|||||||
/* Define a label with the given name */
|
/* Define a label with the given name */
|
||||||
{
|
{
|
||||||
Output ("%s:", Name);
|
Output ("%s:", Name);
|
||||||
LineFeed ();
|
/* Don't start a new line if the label is fully in the left column */
|
||||||
|
if (Col >= MIndent-1) {
|
||||||
|
LineFeed ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DataByteLine (unsigned Count)
|
void DataByteLine (unsigned ByteCount)
|
||||||
/* Output a line with Count data bytes */
|
/* Output a line with bytes */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
Indent (MIndent);
|
Indent (MIndent);
|
||||||
Output (".byte");
|
Output (".byte");
|
||||||
Indent (AIndent);
|
Indent (AIndent);
|
||||||
for (I = 0; I < Count; ++I) {
|
for (I = 0; I < ByteCount; ++I) {
|
||||||
if (I > 0) {
|
if (I > 0) {
|
||||||
Output (",$%02X", CodeBuf[PC+I]);
|
Output (",$%02X", CodeBuf[PC+I]);
|
||||||
} else {
|
} else {
|
||||||
Output ("$%02X", CodeBuf[PC+I]);
|
Output ("$%02X", CodeBuf[PC+I]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LineComment (PC, Count);
|
LineComment (PC, ByteCount);
|
||||||
LineFeed ();
|
LineFeed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DataWordLine (unsigned Count)
|
void DataWordLine (unsigned ByteCount)
|
||||||
/* Output a line with Count data words */
|
/* Output a line with words */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
Indent (MIndent);
|
Indent (MIndent);
|
||||||
Output (".word");
|
Output (".word");
|
||||||
Indent (AIndent);
|
Indent (AIndent);
|
||||||
for (I = 0; I < Count; I += 2) {
|
for (I = 0; I < ByteCount; I += 2) {
|
||||||
if (I > 0) {
|
if (I > 0) {
|
||||||
Output (",$%04X", GetCodeWord (PC+I));
|
Output (",$%04X", GetCodeWord (PC+I));
|
||||||
} else {
|
} else {
|
||||||
Output ("$%04X", GetCodeWord (PC+I));
|
Output ("$%04X", GetCodeWord (PC+I));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LineComment (PC, Count);
|
LineComment (PC, ByteCount);
|
||||||
|
LineFeed ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DataDWordLine (unsigned ByteCount)
|
||||||
|
/* Output a line with dwords */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
Indent (MIndent);
|
||||||
|
Output (".dword");
|
||||||
|
Indent (AIndent);
|
||||||
|
for (I = 0; I < ByteCount; I += 4) {
|
||||||
|
if (I > 0) {
|
||||||
|
Output (",$%08lX", GetCodeDWord (PC+I));
|
||||||
|
} else {
|
||||||
|
Output ("$%08lX", GetCodeDWord (PC+I));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LineComment (PC, ByteCount);
|
||||||
LineFeed ();
|
LineFeed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +231,10 @@ void DataWordLine (unsigned Count)
|
|||||||
void SeparatorLine (void)
|
void SeparatorLine (void)
|
||||||
/* Print a separator line */
|
/* Print a separator line */
|
||||||
{
|
{
|
||||||
Output ("; ----------------------------------------------------------------------------");
|
if (Pass == PassCount && Verbosity >= 1) {
|
||||||
LineFeed ();
|
Output ("; ----------------------------------------------------------------------------");
|
||||||
|
LineFeed ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,12 +242,24 @@ void SeparatorLine (void)
|
|||||||
void LineComment (unsigned PC, unsigned Count)
|
void LineComment (unsigned PC, unsigned Count)
|
||||||
/* Add a line comment with the PC and data bytes */
|
/* Add a line comment with the PC and data bytes */
|
||||||
{
|
{
|
||||||
if (Pass > 1 && Verbosity >= 3) {
|
unsigned I;
|
||||||
|
|
||||||
|
if (Pass == PassCount && Verbosity >= 2) {
|
||||||
Indent (CIndent);
|
Indent (CIndent);
|
||||||
Output ("; %04X", PC);
|
Output ("; %04X", PC);
|
||||||
if (Verbosity >= 4) {
|
if (Verbosity >= 3) {
|
||||||
while (Count--) {
|
for (I = 0; I < Count; ++I) {
|
||||||
Output (" %02X", CodeBuf [PC++]);
|
Output (" %02X", CodeBuf [PC+I]);
|
||||||
|
}
|
||||||
|
if (Verbosity >= 4) {
|
||||||
|
Indent (TIndent);
|
||||||
|
for (I = 0; I < Count; ++I) {
|
||||||
|
unsigned char C = CodeBuf [PC+I];
|
||||||
|
if (!isprint (C)) {
|
||||||
|
C = '.';
|
||||||
|
}
|
||||||
|
Output ("%c", C);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,11 +70,14 @@ void DefLabel (const char* Name);
|
|||||||
void OneDataByte (void);
|
void OneDataByte (void);
|
||||||
/* Output a .byte line with the current code byte */
|
/* Output a .byte line with the current code byte */
|
||||||
|
|
||||||
void DataByteLine (unsigned Count);
|
void DataByteLine (unsigned ByteCount);
|
||||||
/* Output a line with Count data bytes */
|
/* Output a line with bytes */
|
||||||
|
|
||||||
void DataWordLine (unsigned Count);
|
void DataWordLine (unsigned ByteCount);
|
||||||
/* Output a line with Count data words */
|
/* Output a line with words */
|
||||||
|
|
||||||
|
void DataDWordLine (unsigned ByteCount);
|
||||||
|
/* Output a line with dwords */
|
||||||
|
|
||||||
void SeparatorLine (void);
|
void SeparatorLine (void);
|
||||||
/* Print a separator line */
|
/* Print a separator line */
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ typedef enum token_t {
|
|||||||
CFGTOK_CODE,
|
CFGTOK_CODE,
|
||||||
CFGTOK_BYTETAB,
|
CFGTOK_BYTETAB,
|
||||||
CFGTOK_WORDTAB,
|
CFGTOK_WORDTAB,
|
||||||
|
CFGTOK_DWORDTAB,
|
||||||
CFGTOK_ADDRTAB,
|
CFGTOK_ADDRTAB,
|
||||||
CFGTOK_RTSTAB,
|
CFGTOK_RTSTAB,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user