Bug 18553 – Inline assembler: CR2, CR3 control registers not available in 64-bit code

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-03-04T19:25:28Z
Last change time
2018-03-22T07:33:17Z
Assigned to
No Owner
Creator
Jon

Comments

Comment #0 by jonfandrew — 2018-03-04T19:25:28Z
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
Comment #1 by bitter.taste — 2018-03-20T07:56:58Z
Comment #2 by github-bugzilla — 2018-03-22T07:33:16Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/77bab61f3c4ad2fbd5cef4289677e926ff7771ef Fix issue 18553 - Allow mov reg64,crn and mov crn,reg64 Also add support for reading/writing the CR8 register on x64. https://github.com/dlang/dmd/commit/a73766db46abe86fd0c2e74ce60920b0a50669f0 Merge pull request #8017 from LemonBoy/b18553 Fix issue 18553 - Allow mov reg64,crn and mov crn,reg64 merged-on-behalf-of: Walter Bright <[email protected]>