diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-04-13 23:25:06 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-04-13 23:27:57 +0200 |
| commit | e5ca4671acd56408826c6e0d5a7619eaa6d3f33e (patch) | |
| tree | 747aa1e9a113b3a538a38df2cc3c7611752c419d | |
| parent | 4f0229934a4121eeabc14496ec3e9395d5af51f2 (diff) | |
| download | style.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.md | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |
