summaryrefslogtreecommitdiff
path: root/macros/code.asm
diff options
context:
space:
mode:
authorRemy Oukaour <remy.oukaour@gmail.com>2018-01-10 11:57:28 -0500
committerRemy Oukaour <remy.oukaour@gmail.com>2018-01-10 11:57:28 -0500
commitcc95d1208d4a6b8291a5430a8d652a9337074788 (patch)
tree106d9efeef959c9fc5e1321afad24f102ab6dea9 /macros/code.asm
parent22b607b664b1b350ad96340b39440c8e4296006c (diff)
Use maskbits more, and clarify its usage
Diffstat (limited to 'macros/code.asm')
-rw-r--r--macros/code.asm6
1 files changed, 4 insertions, 2 deletions
diff --git a/macros/code.asm b/macros/code.asm
index 5ec214d50..5a0b82a24 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -39,15 +39,17 @@ ENDM
mobile EQUS "ret"
maskbits: MACRO
+; masks just enough bits to cover the argument
+; e.g. "maskbits %00010100" becomes "and %00011111"
; example usage in rejection sampling:
; .loop
; call Random
-; maskbits 30
+; maskbits 30 +- 1
; cp 30
; jr nc, .loop
x = 1
rept 8
-if \1 > x
+if x < (\1)
x = (x + 1) * 2 +- 1
endc
endr