Re: [cc65] da65 hangs in infinite loop

From: Dan <opendtv1yahoo.com>
Date: 2007-06-12 04:16:59
The problem is with DoTable in data.c. In the case
where Count < MemberSize (due to hitting a label), the
PC is not advanced, thus causing the infinite loop.

However, advancing the PC creates a new problem, which
is that the table becomes misaligned. So a more
complicated fix is required, such as:

static unsigned GetSpanOffset (attr_t Style)
/* Get the offset into a given style */
{
    unsigned RemainingBytes = PC - CodeStart;

    unsigned Count = 0;
    while (Count < RemainingBytes) {
	if (GetStyleAttr (PC-Count-1) != 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 */
{
    unsigned BytesLeft;

    /* Count how many bytes may be output. */
    unsigned Count = GetSpan (Style);

	unsigned offset = GetSpanOffset (Style);
	unsigned alignment = offset & (MemberSize-1);
	if (alignment) {
		unsigned newcount = MemberSize - alignment;
		if (newcount < Count)
			Count = newcount;
	}

    /* If the count is less than the member size,
print a row of Count data
     * bytes. We assume here that there is no member
with a size that is less
     * than BytesPerLine.
     */
    if (Count < MemberSize) {
	DataByteLine (Count);
	PC += Count;
	return Count;
    }



 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jun 12 04:17:12 2007

This archive was generated by hypermail 2.1.8 : 2007-06-12 04:17:17 CEST