Is there a way to load a `RIP` register relative address in inline asm?

Adam D. Ruppe destructionator at gmail.com
Tue Jun 18 17:09:48 UTC 2019


On Tuesday, 18 June 2019 at 16:56:18 UTC, Stefanos Baziotis wrote:
> I can't do for example:
>
> lea RAX, [RIP+something];
>
> Generally, RIP does not seem to be available.

The general trick in x86 assembly for this is

call next;
next:
pop EAX;


The call instruction pushes RIP to the stack (for a future ret 
instruction) but if you put it right where you are, you can 
simply pop it right back off the stack into another register.


More information about the Digitalmars-d-learn mailing list