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

Early local labels sort relative to local ones in the current scope #1208

Open
Rangi42 opened this issue Nov 3, 2023 · 1 comment
Open
Labels
enhancement Typically new features; lesser priority than bugs rgblink This affects RGBLINK

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Nov 3, 2023

This .asm:

SECTION "test", ROM0
Bar:
 db 1
.local1  ; Bar.local1
Foo.early  ; early local label (new feature)
.local2  ; Bar.local2
 db 2
.end  ; Bar.end
Foo:
 db 3
.end  ; Foo.end

results in this .sym:

00:0000 Bar
00:0001 Bar.local2
00:0001 Bar.local1
00:0001 Foo.early
00:0002 Bar.end
00:0002 Foo
00:0003 Foo.end

It would be better if Foo sorted before Bar.end. (Would it though?)

@Rangi42 Rangi42 added bug Unexpected behavior / crashes; to be fixed ASAP! rgblink This affects RGBLINK labels Nov 3, 2023
@pinobatch
Copy link
Member

pinobatch commented Nov 3, 2023

If we're putting related symbols together in the file:
You want to sort same-address local labels by the address of the parent label. Build a mapping from parent name to parent address, such as {'Bar': 0x0000, 'Foo': 0x0002}, and then use that as a sort key for same-location labels. Sort by address, then parent address, then global before local.

If we're defining a "primary" name for each location:
If the reader treats the first encountered symbol for a location as the "primary" symbol for a location, you usually don't want an .end label to be primary. This means the writer would need to put .end labels last. Sort by address, then reverse parent address, then global before local. I was skimming the sym spec for a definition of a symbol being primary, and I couldn't find one.

The definition of "attached" in the sym spec has holes. I plan to bring this up as a separate issue, redefining it in terms of "follows".

@Rangi42 Rangi42 added enhancement Typically new features; lesser priority than bugs and removed bug Unexpected behavior / crashes; to be fixed ASAP! labels Nov 7, 2023
@Rangi42 Rangi42 added this to the v0.8.0 milestone Nov 24, 2023
@Rangi42 Rangi42 removed this from the v0.9.0 milestone Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Typically new features; lesser priority than bugs rgblink This affects RGBLINK
Projects
None yet
Development

No branches or pull requests

2 participants