I have a zeroed 128 bit register I want to shift left and add a byte. I can shift it with:
pslldq xmm0, 1
...but now I want to copy al into the empty space. Something like:
or xmm0, al
which of course doesn't work. I only want the lowest 8 bits affected. This will be in a loop where successive values of al will be used to fill the register. So I need some kind of mov instruction or other alternative.
The ideal would be a single instruction to shift left 8 bits and insert but I don't think such exists.
I have spent a lot of time rummaging around in the x86-64 instruction set data but can't find anything that will allow me to do what I want. Can it be done?
UPDATE: I found an error in my code logic after trying pinsrb. pinsrb would be great but unfortunately it can only use an immediate index, not a register.
I'm taking bytes from non contiguous locations so I think I need to do it a byte at a time. The number of bytes can be anywhere from 1 to 16. The first byte I grab should end up in the lowest byte of xmm0, the next byte goes into the next lowest etc.