aboutsummaryrefslogtreecommitdiff
path: root/shared/asm.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-10 22:55:41 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-10 23:22:22 +0100
commitba0cf9e5293f258c58ced1fcc47f558e7419dae4 (patch)
treeb620422506e5b8a951f7e52756c116bfb1498ea3 /shared/asm.s
parent1a74e6a1856673072a61abd0861759901bc2d939 (diff)
downloadcode.nes-ba0cf9e5293f258c58ced1fcc47f558e7419dae4.tar.gz
code.nes-ba0cf9e5293f258c58ced1fcc47f558e7419dae4.zip
Provide an example on multiscreen scrolling
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'shared/asm.s')
-rw-r--r--shared/asm.s22
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/asm.s b/shared/asm.s
new file mode 100644
index 0000000..67b195c
--- /dev/null
+++ b/shared/asm.s
@@ -0,0 +1,22 @@
+;; Jump And Link: jump to subroutine but use the return address that the caller
+;; had whenever the given subroutine runs `rts`. In other words, "link" the
+;; return address from the caller to the callee.
+;;
+;; This is in practice the same as using `jmp` but it bears the semantic
+;; connotation of the `jsr` one. That is, instead of this:
+;;
+;; jsr subroutine
+;; rts
+;;
+;; It's more adviseable to do the following for better stack management:
+;;
+;; jmp subroutine
+;;
+;; That being said, the `jmp` instruction is also used in many other contexts,
+;; and so sometimes it's needed to clarify that: "no, I have not messed up,
+;; using `jmp` here instead of `jsr` is deliberate". Hence, instead of adding a
+;; comment every time this small optimization is being done, use this
+;; pseudo-instruction.
+.macro JAL ADDR
+ jmp ADDR
+.endmacro