One thing that I have seen in various codes is the use of unnamed labels.
I haven't used them myself, but from what I've seen, I assume that : is an unnamed label and that JMP :+ means "go down to the next unnamed label", JMP :- means "go up to the next unnamed label" and JMP :++ means "go down until you are at the second unnamed label that you encounter".
My question is: Why do people use this? Is there any advantage over named labels?
I like the idea of local labels very much, giving me the chance to use names like @end and @loop in multiple functions.
But I've never seen the appeal of unnamed labels.
In fact, I only see disadvantages:
1. When reading the code, you cannot readily see where the jump goes to. You have to take the number of pluses or minuses and then count through all the colons to check where you end up.
With named labels, it is much clearer where the jump goes to. Especially in text editors like Notepad++ where I just need to mark the name and then the other occurences of the name get a colored background.
2. The unnamed labels are error-prone.
Remove a label and forget to remove the references: Your code has just gotten a bug.
Remove a label and forget to update the references that don't even have to do with it, but that point to other unnamed level: Your code has just gotten a bug.
Reorder code (switching around two sections that each start with a label) and forget to switch the number of pluses and minuses elsewhere in the code: Your code has just gotten a bug.
But remove a named label and forget to remove the references and the compiler will give you an error message.
And switch around two code sections that start with named labels and the rest of the code can still remain as it is.
So, where's the advantage? What's the reason to ever use unnamed labels?
I haven't used them myself, but from what I've seen, I assume that : is an unnamed label and that JMP :+ means "go down to the next unnamed label", JMP :- means "go up to the next unnamed label" and JMP :++ means "go down until you are at the second unnamed label that you encounter".
My question is: Why do people use this? Is there any advantage over named labels?
I like the idea of local labels very much, giving me the chance to use names like @end and @loop in multiple functions.
But I've never seen the appeal of unnamed labels.
In fact, I only see disadvantages:
1. When reading the code, you cannot readily see where the jump goes to. You have to take the number of pluses or minuses and then count through all the colons to check where you end up.
With named labels, it is much clearer where the jump goes to. Especially in text editors like Notepad++ where I just need to mark the name and then the other occurences of the name get a colored background.
2. The unnamed labels are error-prone.
Remove a label and forget to remove the references: Your code has just gotten a bug.
Remove a label and forget to update the references that don't even have to do with it, but that point to other unnamed level: Your code has just gotten a bug.
Reorder code (switching around two sections that each start with a label) and forget to switch the number of pluses and minuses elsewhere in the code: Your code has just gotten a bug.
But remove a named label and forget to remove the references and the compiler will give you an error message.
And switch around two code sections that start with named labels and the rest of the code can still remain as it is.
So, where's the advantage? What's the reason to ever use unnamed labels?