Comment by bombcar
4 years ago
It seems to me that the elegant solution would involve an instruction that returns the first non-zero bit of the number - but I don’t know if such a instruction exists in assembly.
4 years ago
It seems to me that the elegant solution would involve an instruction that returns the first non-zero bit of the number - but I don’t know if such a instruction exists in assembly.
Basically lzcnt or leading zero count on x86: https://www.felixcloutier.com/x86/lzcnt
> It should be noted that on processors that do not support LZCNT, the instruction byte encoding is executed as BSR.
This. Boggles.
https://stackoverflow.com/a/43443701 - interesting - it seems to be a side effect of changing meaning of an instruction.