Some AMD64/x86 commands expect immediate values as operands (e.g. imm8). Is it possible to use a value stored in some register (e.g. ah) instead of this hard coded value?
As example:
If I want to shift a xmm register, there is the the pslldq-command:
PSLLDQ xmm1, imm8
I have to shift it n times (whereby n is stored in a register). Is it possible to do it without conditional jump?
You could emulate it with a pshufb and a lookup table.
shl eax, 4
pshufb xmm0, [lut + eax]
The lookup table would start with (I think)
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
80 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E
80 80 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D
You could also use plain old unaligned reads, and use nothing "weird": (not tested)
movdqa [temp + 16], xmm0
pxor xmm0, xmm0
movdqa [temp], xmm0
neg eax
movdqu xmm0, [eax + temp + 16]
But that may suffer from a store forwarding failure, which may cost a dozen cycles.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With