diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-07-10 20:06:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-10 20:06:25 -0400 |
commit | 4fb008844030283ad34cb0802b088b4dd7c9891c (patch) | |
tree | 6854c5ea9c5311b677bfbcae0616f0979b754060 /macros/const.asm | |
parent | 9e4a00af4523cdfacbb6b245679e2e60fbc6b375 (diff) | |
parent | c086de0c986330b09cd5e9fa384b950107ee4955 (diff) |
Merge pull request #740 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 000000000..5dfc3bca1 --- /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 |