Skip to content

Transpiler: unresolved branch label in large programs #295

@jonathanpeppers

Description

@jonathanpeppers

Problem

When transpiling the crypto sample (PR #211), after fixing the OamSpr and byte comparison issues, the transpiler successfully generates 6502 code but fails during label resolution:

UnresolvedLabelException: Unresolved label: 'instruction_117D'
   at dotnes.ObjectModel.RelativeOperand.ToBytes(...)
   at dotnes.ObjectModel.Program6502.ToBytes()

A branch instruction references IL offset 0x117D but no matching label was emitted in the 6502 code. This means the transpiler processed all IL instructions but a conditional branch targets an instruction that was either skipped or absorbed by a pattern-matching handler (e.g., the oam_spr or if-block handler consumed instructions that should have had labels).

Context

This occurs in the 2,270-line crypto dungeon crawler sample which has deeply nested conditionals, 189 oam_spr/oam_meta_spr calls, and complex game logic. The IL offset 0x117D corresponds to a branch target deep in the game loop.

Expected

The transpiler should emit labels for all branch targets, even when the target instruction is consumed by a pattern-matching handler.

Workaround

None known -- this requires investigating which IL handler is consuming the target instruction without preserving its label.

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