www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18553] New: Inline assembler: CR2, CR3 control registers not

https://issues.dlang.org/show_bug.cgi?id=18553

          Issue ID: 18553
           Summary: Inline assembler: CR2, CR3 control registers not
                    available in 64-bit code
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: jonfandrew gmail.com

The following code fails to compile in 64-bit mode, even though CR2 and CR3
become 64-bit registers in 64-bit code.

void main()
{
        size_t faultAddress;

        asm
        {
                mov RAX, CR2;
                mov faultAddress[RBP], RAX;
        }
}

The equivalent 32-bit code compiles fine when using dmd -m32:

void main()
{
        size_t faultAddress;

        asm
        {
                mov EAX, CR2;
                mov faultAddress[EBP], EAX;
        }
}

I think adding CR2 and CR3 to the regtab64 array in iasm.d will correct the
problem, but I'm not super smart on the compiler internals and didn't want to
embarrass myself with an ignorant PR.

-Doc

--
Mar 04 2018