Skip to content

SPC700 dbnz and cbne instructions have an improper error condition that triggers on valid code #348

@exodustx0

Description

@exodustx0

Reproducer:

asar 1.90
arch spc700
norom

org $0123 ; has to be $007F or higher
Foo: assert 0 != Foo ; has to have a label on rhs

- dbnz Y, -

This prints Errors were detected while assembling the patch. Assembling aborted. Your ROM has not been modified. and nothing more. The error is thrown from arch-spc700.cpp#L346, but only on pass 1, not the pass 2 which causes the actual error (relative_branch_out_of_bounds) to be printed (which is an incorrect error).

If you remove the assert (or have rhs not be a label), the only reason this error is not thrown on pass 1 is because foundlabel is false. However, in the assert code, the getnumdouble() call on Foo sets foundlabel = true and it thereafter is never reset, it persists until the dbnz code.

I am unable to tell where the resetting should've taken place. For that matter, I generally have trouble wrapping my head around Asar's assembler state, so I'm not excluding the possibility that I'm missing some context and it's some other piece of the puzzle where the bug resides.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions