Early local labels sort relative to local ones in the current scope
Rangi42 opened this issue · 1 comments
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?)
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".