aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-13 23:25:06 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-13 23:27:57 +0200
commite5ca4671acd56408826c6e0d5a7619eaa6d3f33e (patch)
tree747aa1e9a113b3a538a38df2cc3c7611752c419d
parent4f0229934a4121eeabc14496ec3e9395d5af51f2 (diff)
downloadstyle.nes-e5ca4671acd56408826c6e0d5a7619eaa6d3f33e.tar.gz
style.nes-e5ca4671acd56408826c6e0d5a7619eaa6d3f33e.zip
Add a note on numeric literals
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--README.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index 53b07d1..01c4847 100644
--- a/README.md
+++ b/README.md
@@ -173,6 +173,24 @@ your editor (and this repository also holds an [.editorconfig](./.editorconfig)
to help you on this). If your editor doesn't support some of these options, just
replace it.
+# Numeric literals
+
+In 6502 assembly you can express numeric literals in decimal, hexadecimal and
+binary formats. One useful rule I have been developing over the course of
+programming in 6502 assembly is:
+
+1. Prefer the hexadecimal format: debuggers, emulators, ROM dumps, and related
+ tooling will default to this format.
+2. Use the decimal format for simple numbers which can be trivially translated
+ into hexadecimal format, but which are more simple to write this way
+ (e.g. `lda #0`).
+3. Use binary format for bitmap masks, or other arrangements where each bit has
+ been set/unset following a very strict order (e.g. preparing the value for a
+ PPU register). As for masks, it might be quite trivial to mentally parse
+ which bits are set/unset with something like `lda #$81`, but something like
+ `lda #$AC` might take more time to mentally parse than the more explicit `lda
+ #%10101100`.
+
# Allocation conventions
I am not going to reinvent the wheel here: just stick to the comments on the