Skip to content

Opt-in link-time lint warnings, e.g. when ld can be ldh, or jp can be jr #1017

Open
@Rangi42

Description

@Rangi42

These would be useful as opt-in link-time warnings:

  • For every ld, check for and suggest using ldh instead if possible.

    (This would be an improved substitute for the removed feature of rgbasm -L, which optimized known-constant ld to ldh.)

  • For every jp, check for and suggest using jr instead if possible.

  • For every control flow instruction (call, jp, jr, rst) targeting a label in ROMX, do a lint equivalent of assert BANK(@) == 0 || BANK(<target>) == 0 || BANK(@) == BANK(<target>).

    (rst always targets ROM0, but if we add support for swappable ROM0, possibly via HDFs ([Feature request/proposal] Hardware layout description files (custom mapper support) #524), then this would be multi-banked.)

    Do this only if PC is in a ROMX section, which also excludes LOAD. (In theory, BANK(@) != 0 for ROMX, but -t maps ROMX to ROM0. The destination is then guaranteed to be in ROM0 as well, but that may not remain the case if we add some similar feature to HDFs, so a cheap stringent check for BANK(@) == 0 is good for future-proofing.)

    (Possibly make this a multi-level lint, where by default cross-SECTION jumps are not checked?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementTypically new features; lesser priority than bugsrgbasmThis affects RGBASMrgblinkThis affects RGBLINK

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions