3 ms·
PCMPISTRI, what an instruction. It's supposed to be a comparison, but it doesn't set the flags with comparison results. Instead it uses them to signal if it's
by kwillets 9y ago
PCMPISTRI, what an instruction.
It's supposed to be a comparison, but it doesn't set the flags with comparison results. Instead it uses them to signal if it's found an unequal byte, or hit the end of the strings. The latter is equality, which is one condition we want, but it doesn't say where in the 16 bytes it found the terminator. In fact it sets the register (ecx) which otherwise would be the offset to compare bytes, to 16.
That's all fine if you just want to return string comparison, but if you're trying to find their longest common prefix it's a whole new comparison to find the 0x00's.