diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 |
