2 ms·
But on x86, division by 2 on an unsigned integer is the same as shifting to the right by 1. So instead of even: mov rbx, 2 xor rdx, rdx
by colejohnson66 9y ago
But on x86, division by 2 on an unsigned integer is the same as shifting to the right by 1. So instead of
even:
mov rbx, 2
xor rdx, rdx
div rbx
the OP should've done something like
even:
xor rdx, rdx % possible to remove?
shr rbx, 1
- hrydgard 9y agoYour second snippet will just zero rdx - don't confuse the registers (rbx is in the mix in the original :)
- colejohnson66 9y agoThanks :) Fixed.
- pwdisswordfish 9y agoshr rax, 1 div rbx will divide the 128-bit value in (rdx, rax) by rbx, then store the quotient in rax and the remainder in rdx.