aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-13 23:35:44 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-13 23:40:17 +0200
commit65ea11eb0dfd29f572e83a2f3fe77d992e115b1c (patch)
treef24fc08ec8c447c1f465a7db6bdbea1bb1aeebd8 /README.md
parente5ca4671acd56408826c6e0d5a7619eaa6d3f33e (diff)
downloadstyle.nes-65ea11eb0dfd29f572e83a2f3fe77d992e115b1c.tar.gz
style.nes-65ea11eb0dfd29f572e83a2f3fe77d992e115b1c.zip
Add a note on indirect jumps
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md15
1 files changed, 12 insertions, 3 deletions
diff --git a/README.md b/README.md
index 01c4847..33ebf85 100644
--- a/README.md
+++ b/README.md
@@ -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