Example #1
0
void DataDWordLine (unsigned ByteCount)
/* Output a line with dwords */
{
    unsigned I;

    Indent (MCol);
    Output (".dword");
    Indent (ACol);
    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 ();
}
Example #2
0
void DataDByteLine (unsigned ByteCount)
/* Output a line with dbytes */
{
    unsigned I;

    Indent (MCol);
    Output (".dbyt");
    Indent (ACol);
    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 ();
}
Example #3
0
void DataByteLine (unsigned ByteCount)
/* Output a line with bytes */
{
    unsigned I;

    Indent (MCol);
    Output (".byte");
    Indent (ACol);
    for (I = 0; I < ByteCount; ++I) {
        if (I > 0) {
            Output (",$%02X", CodeBuf[PC+I]);
        } else {
            Output ("$%02X", CodeBuf[PC+I]);
        }
    }
    LineComment (PC, ByteCount);
    LineFeed ();
}
Example #4
0
static void OneLine (const OpcDesc* D, const char* Arg, ...)
/* Output one line with the given mnemonic and argument */
{
    char Buf [256];
    va_list ap;

    /* Mnemonic */
    Mnemonic (D->Mnemo);

    /* Argument */
    va_start (ap, Arg);
    xvsprintf (Buf, sizeof (Buf), Arg, ap);
    va_end (ap);
    Indent (ACol);
    Output ("%s", Buf);

    /* Add the code stuff as comment */
    LineComment (PC, D->Size);

    /* End the line */
    LineFeed ();
}
Example #5
0
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 (MCol);
            Output (".byte");
            Indent (ACol);
            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;
}
Example #6
0
unsigned RtsTable (void)
/* Output a table of RTS addresses (address - 1) */
{
    unsigned long BytesLeft = GetRemainingBytes ();
    unsigned long Start = PC;

    /* Loop while table bytes left and we don't need to create a label at the
    ** current position.
    */
    while (BytesLeft && GetStyleAttr (PC) == atRtsTab) {

        unsigned Addr;

        /* If just one byte is left, define it and bail out */
        if (BytesLeft == 1 || GetStyleAttr (PC+1) != atRtsTab) {
            DataByteLine (1);
            ++PC;
            break;
        }

        /* More than one byte left. Define a forward label if necessary */
        ForwardLabel (1);

        /* Now get the address from the PC */
        Addr = (GetCodeWord (PC) + 1) & 0xFFFF;

        /* In pass 1, define a label, in pass 2 output the line */
        if (Pass == 1) {
            if (!HaveLabel (Addr)) {
                AddIntLabel (Addr);
            }
        } else {
            const char* Label = GetLabel (Addr, PC);
            if (Label == 0) {
                /* OOPS! Should not happen */
                Internal ("OOPS - Label for address 0x%06X disappeard!", Addr);
            }
            Indent (MCol);
            Output (".word");
            Indent (ACol);
            Output ("%s-1", Label);
            LineComment (PC, 2);
            LineFeed ();
        }

        /* Next table entry */
        PC        += 2;
        BytesLeft -= 2;

        /* If we must define a label here, bail out */
        if (BytesLeft && MustDefLabel (PC)) {
            break;
        }
    }

    /* If the next line is not a return address table line, add a separator */
    if (CodeLeft() && GetStyleAttr (PC) != atRtsTab) {
        SeparatorLine ();
    }

    /* Return the number of bytes output */
    return PC - Start;
}