diff options
| -rw-r--r-- | README.md | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -437,7 +437,7 @@ already telling the caller that the `x` register is involved on this scenario. ## Use `.proc` for functions The `.proc` control statement guarantees a new lexical scope, so named labels -will not clash with named labels from other scopes. There are really no +will not clash with named labels from other scopes. There are (almost) no downsides to it. ``` assembly @@ -449,8 +449,17 @@ bad: .endproc ``` -Hence, labels should only be used for control flow and referencing data on ROM -space. +I say "(almost)" as I have seen at least one situation in which discarding any +kind of scoping could be useful if performance was paramount. That is, imagine a +16-bit pointer to a function that can be set to different handlers for enemy +movement. This could be done in multiple ways, but the most performant way would +be to just `jmp (pointer)`, and then let each handler perform a `jmp +@known_return_address` instead of a mere `rts`. Hence, if you are on corner +cases like these, I think it's fair to go the optimal route. In other cases, +prefer readability. + +Otherwise, labels should only be used for control flow and referencing data on +ROM space. ## Avoid too many anonymous labels |
