Avoid "+- 1" at every maskbits

This commit is contained in:
Remy Oukaour
2018-01-16 17:27:50 -05:00
parent 8048082114
commit 7b3de85a06
32 changed files with 79 additions and 76 deletions

View File

@@ -37,17 +37,17 @@ ENDM
maskbits: MACRO
; masks just enough bits to cover the argument
; e.g. "maskbits %00010100" becomes "and %00011111"
; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001)
; example usage in rejection sampling:
; .loop
; call Random
; maskbits 30 +- 1
; maskbits 30
; cp 30
; jr nc, .loop
x = 1
rept 8
if x < (\1)
x = (x + 1) * 2 +- 1
if x + 1 < (\1)
x = x << 1 | 1
endc
endr
and x