diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-07-11 15:47:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-11 15:47:19 -0400 |
commit | aa97e196dd5b37e89db5ddf154dc7aea9b02a045 (patch) | |
tree | c994a1ca8f587d674e680ec808e7fcbaab4d053d /macros/const.asm | |
parent | 54d76dec388a70260aad6ef6acb94a5b9f95fd6d (diff) | |
parent | 3e572b6f48b81e5340980c13b1b37b2907942713 (diff) |
Merge pull request #269 from Rangi42/master
Remove enum; add const_skip and const_next
Diffstat (limited to 'macros/const.asm')
-rw-r--r-- | macros/const.asm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/macros/const.asm b/macros/const.asm new file mode 100644 index 00000000..57380e97 --- /dev/null +++ b/macros/const.asm @@ -0,0 +1,40 @@ +; Enumerate constants + +const_def: MACRO +IF _NARG >= 1 +const_value = \1 +ELSE +const_value = 0 +ENDC +IF _NARG >= 2 +const_inc = \2 +ELSE +const_inc = 1 +ENDC +ENDM + +const: MACRO +\1 EQU const_value +const_value = const_value + const_inc +ENDM + +shift_const: MACRO +\1 EQU (1 << const_value) +const_value = const_value + const_inc +ENDM + +const_skip: MACRO +if _NARG >= 1 +const_value = const_value + const_inc * (\1) +else +const_value = const_value + const_inc +endc +ENDM + +const_next: MACRO +if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value) +fail "const_next cannot go backwards from {const_value} to \1" +else +const_value = \1 +endc +ENDM |