Hi everyone,
So I've found a small inconsistency on x86_64 with inline assembly, specificially the PINSRW instruction. Under AT&T notation, you can write something like this and it will compile fine with the internal assembler:
pinsrw $0x0, %dx, %xmm0
But if you use -a so the external assembler is used, it throws an error, because the second parameter can either be a 16-bit memory location, or a 32-bit register... not 16-bit. In other words, even though the upper 16 bits aren't used on the register for this instruction, you must specify the full 32-bit register:
pinsrw $0x0, %edx, %xmm0
This is confirmed on page 4-296 of Vol. 2B of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, showing the second parameter is of the form "r32/m16".
Long story short, "pinsrw $0x0, %dx, %xmm0" is technically illegal even if it makes more logical sense. I put this down to PINSRW being a carry-over from the MMX instruction set and possibly not designed as well as it could be. Should the internal assembler / syntax checker be changed to trap this?
Gareth aka. Kit
