Skip to content

Abnormally large number of iterations #246

@vxgmichel

Description

@vxgmichel

While assembling this file, I produced about 1800 errors of the form <something> did not converge.

It took me a while to realize that it wasn't cyclic error, but simply that customasm required more than 10 iterations (the default limit) to complete. It actually required 19 iterations:

± customasm smb.asm -t 50                         
customasm v0.14.0 (x86_64-unknown-linux-gnu)
assembling `smb.asm`...
writing `smb.bin`...
resolved in 19 iterations

The weird part is that the number of iteration decreases to 4 iterations when the assertion reladdr >= !0x7f (line 7) of cpu6502_reladdr is commented out:

#subruledef cpu6502_reladdr
{
{addr: u16} =>
{
reladdr = addr - $ - 2
$assert(reladdr <= 0x7f)
$assert(reladdr >= !0x7f)
reladdr`8
}
}

That's a bit surprising since the cpu6502_reladdr type doesn't seem to be used conditionally, meaning that the corresponding instructions using this value (bcc, bcs, beq, bni, bpe, bpl, bvc and bvs) are either invalid or 2-bytes long.

Maybe there is a subtle bug or a possible optimization for this specific use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions