NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: wanghua131 on September 26, 2018, 01:01:02 AM
-
The assembler code is: PCMPESTRI XMM6, XMM13, 0x45, I want to generate the code which the REX.W =1, but the NASM generate the the code is : 66410F3A61F545, 0x41 is the REX prefix, the REX.W = 0, how to set the REX.W=1 when the NASM generates the code?
-
Instructions PCMPESTRM (http://www.felixcloutier.com/x86/PCMPESTRM.html) and PCMPESTRI (http://www.felixcloutier.com/x86/PCMPESTRI.html) expect the length of input strings provided in registers EAX and EDX. When the instruction is encoded with prefix REX.W, RAX and RDX are used instead.
Value in length-registers is saturated to 8 or 16, so the need of REX.W can be bypassed with manual extension of 32bit value to 64 bits:
XCHG RAX,RDX
CDQE
XCHG RDX, RAX
CDQE
PCMPESTRI XMM6,XMM13,0x45
But you are right, AMD and Intel do not suggest any specification how to ask for 64bit version of length-registers, so it depends on assembler manufacturers, and it is often overlooked. Thank you for reminding. Possible solutions which occured me:
- Explicit prefix request:
REX.W PCMPESTRI XMM6,XMM13,0x45
- Explicit notation of hardwired length-registers as additional operands:
PCMPESTRI XMM6,XMM13,0x45,RAX,RDX
- Modification of mnemonic name:
PCMPESTRI64 XMM6,XMM13,0x45
or PCMPESTRIQ XMM6,XMM13,0x45
PCMPESTRI XMM6,XMM13,0x45,DWORD[/li][/list]
Current version of NASM doesn't allow any of this possibilities, AFAIK. I completed €ASM with the fourth variant today, see this test example (https://euroassembler.eu/eatests/t3820.htm).[/list]
-
Thank you very much!