Added -d/--debug and -m/--multi-pass switches to the disassembler. The latter

will make the disassembler run multiple preparation passes to find all
addresses where labels must be placed. Without -m some label addresses are
found in the final pass, where the disassembler cannot make use of them.
This commit is contained in:
Kugel Fuhr
2025-06-20 13:00:12 +02:00
parent c520455b2b
commit 4c81eacefe
7 changed files with 113 additions and 15 deletions

View File

@@ -124,7 +124,7 @@ void CloseOutput (void)
void Output (const char* Format, ...)
/* Write to the output file */
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
va_list ap;
va_start (ap, Format);
Col += vfprintf (F, Format, ap);
@@ -137,7 +137,7 @@ void Output (const char* Format, ...)
void Indent (unsigned N)
/* Make sure the current line column is at position N (zero based) */
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
while (Col < N) {
fputc (' ', F);
++Col;
@@ -150,7 +150,7 @@ void Indent (unsigned N)
void LineFeed (void)
/* Add a linefeed to the output file */
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
fputc ('\n', F);
if (PageLength > 0 && ++Line >= PageLength) {
if (FormFeeds) {
@@ -185,7 +185,7 @@ void DefForward (const char* Name, const char* Comment, unsigned Offs)
** current PC.
*/
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
/* Flush existing output if necessary */
if (Col > 1) {
LineFeed ();
@@ -212,7 +212,7 @@ void DefForward (const char* Name, const char* Comment, unsigned Offs)
void DefConst (const char* Name, const char* Comment, uint32_t Addr)
/* Define an address constant */
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
Output ("%s", Name);
Indent (ACol);
Output (":= $%04" PRIX32, Addr);
@@ -313,7 +313,7 @@ void DataDWordLine (uint32_t ByteCount)
void SeparatorLine (void)
/* Print a separator line */
{
if (Pass == PassCount && Comments >= 1) {
if (Pass == PASS_FINAL && Comments >= 1) {
Output ("; ----------------------------------------------------------------------------");
LineFeed ();
}
@@ -324,7 +324,7 @@ void SeparatorLine (void)
void StartSegment (const char* Name, unsigned AddrSize)
/* Start a segment */
{
if (Pass == PassCount) {
if (Pass == PASS_FINAL) {
LineFeed ();
Output (".segment");
Indent (ACol);
@@ -368,7 +368,7 @@ void LineComment (unsigned PC, unsigned Count)
{
unsigned I;
if (Pass == PassCount && Comments >= 2) {
if (Pass == PASS_FINAL && Comments >= 2) {
Indent (CCol);
Output ("; %04X", PC);
if (Comments >= 3) {