; round up to a power of two logtwoup: xor eax, eax bsr rsi, rdi ; rsi has the log 2 rounded down bts rax, rsi cmp rax, rdi jz .done shr rax, 1 .done: ret