From efcf72fa8d546070995254253753d7ab7b2dcce1 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 10 Feb 2025 10:32:02 +0100 Subject: Clarify constants as upper case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d57385b..f57193d 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,7 @@ By simply looking at this you quickly know that: Even if the name turns out to not be too flashy, it's imperative when writing assembly code to be as clear as possible. -## UPPER_CASE for macros and aliases to memory-mapped I/O +## UPPER_CASE for macros and regular constants In a similar spirit as many code styles for C, use `UPPER_CASE` for macros, as that makes it more apparent what they are. @@ -269,13 +269,18 @@ that makes it more apparent what they are. .endmacro ``` -In a similar way, there are some assignments which are simply aliases to -memory-mapped I/O. These "variables" are to be defined also in upper case as -they are quite special. +In a similar way, there are assignments which are simply a way to name regular +numeric constants. This differs to how "variables" are assigned as they are not +memory addresses that the CPU can directly access. Hence, for constant numbers +or memory addresses which are not directly tied to the CPU (i.e. memory-mapped +I/O), use upper case in the same way you would in C. ``` assembly lda PPU::m_control ; bad! lda PPU::CONTROL ; good! + +bad_constant = 1 +GOOD_CONSTANT = 1 ``` # Calling conventions -- cgit v1.2.3