Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow label aliases #158

Open
fadden opened this issue May 16, 2024 · 0 comments
Open

Allow label aliases #158

fadden opened this issue May 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@fadden
Copy link
Owner

fadden commented May 16, 2024

Sometimes an address represents more than one thing. A somewhat contrived example:

         ldx #$7f
         jsr Delay
         ...

Delay    dex
         bne Delay
         rts

It might be more readable to separate the entry point from the loop:

Delay
@Loop    dex
         bne @Loop
         rts

This can also be useful for data items. For example, suppose we have variables that are accessed directly and by index:

thing0   .byte $22
thing1   .byte $33
thing2   .byte $44

         lda thing1
         sta thing2
         ldy thing_index
         lda thing0,Y

We'd really prefer it to be:

thing_list
thing0   .byte $22
thing1   .byte $33
thing2   .byte $44

         lda thing1
         sta thing2
         ldy thing_index
         lda thing_list,Y

We can introduce a notion of "label aliases" that associate a second label with a single file offset.

I've found a couple of projects in the wild that were trying to do something similar by using the address region pre-label feature, but that's not intended for this purpose.

Things to be figured out:

  • How to display on screen. Probably just put the label on a line by itself, like we do for address region pre-labels. The alias comes first, on its own line, immediately before the primary definition. (It'd be nifty to figure out how to put long comments between the alias and primary, but that might be awkward.)
  • Editor UI definition. Could add an always-present second text field to Edit Label, or add an "add alias" button. Assuming the feature is used rarely, a multi-click but low-clutter option would be preferred. I do think this belongs within the Edit Label dialog; adding to the app menu seems wrong.
    • Double-clicking on the alias must open the correct editor. Could allow deletion with the Del key, or require use of the dialog.
  • Various minor symbol stuff:
    • Add the alias to the Symbols list. (Don't think we need a new filter button for them.)
    • Make cross-references work, i.e. show the correct References when the alias line is selected.
    • Make sure "goto symbol" works.
  • Impact on label localization during asm generation. We'd presumably want to allow the alias to be local or global, so the label localizer would need to be updated to handle them. (Pre-labels are always global.)
  • Address resolution. The primary label is always the one used when automatically resolving an address reference. The alias label must be specified explicitly. (Could have an affordance in the Edit Operand dialogs that lets you switch between them with one click.)
@fadden fadden added the enhancement New feature or request label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant