Why is the rex.w prefix not generated for certain instructions in inline assembler blocks?
Joseph Cassman
jc7919 at outlook.com
Mon Sep 9 13:37:44 PDT 2013
The following artificial code sample fails to compile (DMD
2.063.2 run on Ubuntu 13.04 on an AMD Athlon II X4 635 processor)
void main()
{
asm
{
mov RAX,0x1ffffffffUL;
mov R8,0x1ffffffffUL;
and RAX,0xffffffffUL;
and R8,0xffffffffUL;
and RAX,0x1ffffffffUL;
}
}
with this error
phi/rex.d(9): Error: bad type/size of operands 'and'
Failed: 'dmd' '-v' '-o-' 'phi/rex.d' '-Iphi'
The error also appears for registers RBX,RCX,RDX,R8 through R15
and the instructions or,xor,add,sub,cmp.
From what I understand from the Intel documentation the registers
R8 through R15 can be accessed by prefixing an instruction with
an REX.R opcode. And an opcode prefix of REX.W promotes an
instruction to 64-bits. I was thinking that this opcode was not
being generated by the compiler. But the disassembly I get (using
obj2asm, after removing the last statement that will not compile)
leads me to believe that no particular opcode is provided.
mov RAX,01FFFFFFFFh
mov R8,01FFFFFFFFh
and EAX,0FFFFFFFFh
and R8,0FFFFFFFFh
So I'm out of ideas on where the error is coming from. Anyone got
any ideas on what's going on here?
Thanks
Joseph
More information about the Digitalmars-d-learn
mailing list