aboutsummaryrefslogtreecommitdiffstats
path: root/macros
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2024-12-27 12:52:30 -0500
committerGitHub <noreply@github.com>2024-12-27 12:52:30 -0500
commitf8a7ac34b90acb71122d71c89aa8e95b4346cf20 (patch)
treeedffd155c9eb0adcea7517c2303f1c2d50021774 /macros
parentRemove `-Wnumeric-string=2` (diff)
downloadpokeyellow-f8a7ac34b90acb71122d71c89aa8e95b4346cf20.tar.gz
pokeyellow-f8a7ac34b90acb71122d71c89aa8e95b4346cf20.tar.xz
pokeyellow-f8a7ac34b90acb71122d71c89aa8e95b4346cf20.zip
Don't pass redundant label names to `table_width` and `list_start` (#125)
Diffstat (limited to 'macros')
-rw-r--r--macros/asserts.asm35
1 files changed, 23 insertions, 12 deletions
diff --git a/macros/asserts.asm b/macros/asserts.asm
index bc5b2582..7fb7f96b 100644
--- a/macros/asserts.asm
+++ b/macros/asserts.asm
@@ -1,13 +1,29 @@
; Macros to verify assumptions about the data or code
+MACRO _redef_current_label
+ IF DEF(\1)
+ PURGE \1
+ ENDC
+ IF _NARG == 3 + (\3)
+ DEF \1 EQUS "\<_NARG>"
+ ELIF DEF(..)
+ IF .. - @ == 0
+ DEF \1 EQUS "{..}"
+ ENDC
+ ELIF DEF(.)
+ if . - @ == 0
+ DEF \1 EQUS "{.}"
+ ENDC
+ ENDC
+ if !DEF(\1)
+ DEF \1 EQUS \2
+ {\1}:
+ ENDC
+ENDM
+
MACRO table_width
DEF CURRENT_TABLE_WIDTH = \1
- IF _NARG == 2
- REDEF CURRENT_TABLE_START EQUS "\2"
- ELSE
- REDEF CURRENT_TABLE_START EQUS "._table_width\@"
- {CURRENT_TABLE_START}:
- ENDC
+ _redef_current_label CURRENT_TABLE_START, "._table_width\@", 2, \#
ENDM
MACRO assert_table_length
@@ -24,12 +40,7 @@ ENDM
MACRO list_start
DEF list_index = 0
- IF _NARG == 1
- REDEF CURRENT_LIST_START EQUS "\1"
- ELSE
- REDEF CURRENT_LIST_START EQUS "._list_start\@"
- {CURRENT_LIST_START}:
- ENDC
+ _redef_current_label CURRENT_LIST_START, "._list_start\@", 1, \#
ENDM
MACRO li