aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-11 21:55:30 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-11 21:55:30 +0100
commitc751ceaf07ae9be514e7b6414730fe0919a75e54 (patch)
tree1781bcdf5ae6f47fd59721220e37ea268a4c938a
parentb2db09ecfbabec3cc8087d250e895624d151f4d2 (diff)
downloadstyle.nes-c751ceaf07ae9be514e7b6414730fe0919a75e54.tar.gz
style.nes-c751ceaf07ae9be514e7b6414730fe0919a75e54.zip
Add a note on pseudo-instructions
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rw-r--r--README.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8b6d5b8..5aff6a7 100644
--- a/README.md
+++ b/README.md
@@ -245,6 +245,28 @@ LDA #01 ; bad!
lda #01 ; good!
```
+One good idea for `.macro` is to use them to define pseudo-instructions, as it's
+done in other assembly languages like RISC-V. For example, on [these scrolling
+examples](https://github.com/mssola/code.nes/tree/main/scroll) there is a macro
+for the pseudo-instruction `JAL`, which makes explicit when a `jmp` has been
+used instead of `jsr` for reducing the stack usage on tail calls. In this
+scenario, you can find code like this:
+
+```assembly
+.proc foo
+ ;; Previous code that might jump/branch to @end.
+
+ lda Some::Variable
+ bne @end
+ JAL prepare_next_column
+@end:
+ rts
+.endproc
+```
+
+Here the casing makes explicit that `JAL` is actually a pseudo-instruction, and
+so that it follows somewhat different rules than the ones by its side.
+
## Use the `@` prefix for named labels which affect the control flow
Named labels which are part of the control flow are to use the `@` symbol as a