Why is a 16-bit register used with BSR instruction in this code snippet?
- by sharptooth
In this hardcore article there's a function find_maskwidth() that basically detects the number of bits required to represent itemCount dictinct values:
unsigned int find_maskwidth( unsigned int itemCount )
{
unsigned int maskWidth, count = itemCount;
__asm {
mov eax, count
mov ecx, 0
mov maskWidth, ecx
dec eax
bsr cx, ax
jz next
inc cx
mov maskWidth, ecx
next:
}
return maskWidth;
}
the question is why do they use ax and cx registers instead of eax and ecx?