Assembly - 64-bit registers supported?

Era Scarecrow rtcvb32 at yahoo.com
Sat Jan 19 13:36:29 PST 2013


On Saturday, 19 January 2013 at 12:45:06 UTC, deed wrote:
> void main()
> {
>     asm
>     {
>         mov    RAX, 3;
>     }
> }
>
> results in:
> Error: undefined identifier 'RAX'
>
> AX and EAX work.
>
> Anything missing or isn't it yet implemented?

  Hmm. I know there's a one byte 'escape code' that for x86 allows 
you to force it to a higher/lower level, perhaps that was just 
the 16/32 bit code and won't work for 64bit (different escape 
code?). I think it was 0x66, so you might get away 'db' 
prepending that, but I wouldn't rely on it. Sides there's lots of 
little intricacies of the instruction set; like you could have a 
one byte assignment to any register; That's assuming they aren't 
taking them away in the 64bit versions of x86.

  So...
   asm
   {
      db 66h;
      mov    EAX, 3;   //may work, likely 1 byte assignment
      db 66h;
      mov    EAX, 300; //4 byte assignment from 32bit register
      //4 byte padding needed for 64bit.
      //Little endian would allow this to work
      db 0,0,0,0;
   }

  But that's mostly informational, refer to the technical manual 
from Intel  before attempting.

  Hmmm I wonder, with the 64 bit systems, do they still use the 
segment registers (CS, DS, SS)? I can see it being used for 
telling apart virtual memory and code/data, but not for hardly 
anything else; Plus it's original use has long since been 
unneeded.


More information about the Digitalmars-d-learn mailing list