Hey there, I was wondering how one would go about labeling parts of their code in assembly in order to deal/avoid duplicate names.
Let's say I have foo() and bar() which both for some reason or another really need the same name for a label. Can this be done?
Of course it is possible to give larger and larger names to avoid duplicates, but this seems counterproductive to readability.
I saw someone use the .SET directive to set the value of a label to the PC, which is a clever workaround, however the following code wouldn't work as expected:
foo: .set loop = pc // foo loop that calls bar rcall bar // some branch code rjmp loop ret bar: .set loop = pc // important loop code ret
The loop label never gets reset to what it was when defined initially in foo.
EDIT: there was a misconception where I assumed .set was called at run-time which of course is nonsense! The example code would work just fine.