Re: RIP relative adresses




"cr88192" wrote:

just figured, maybe a few people can offer comments here:
some assemblers apparently make RIP-relative addressing the default in
long-mode, and others making absolute the default.

for example, in many assemblers:
mov rax, [foo]

...

foo dq 0x0123456789ABCDEF

handles this by making 'foo' by default accessed via a RIP-relative
address.

I'd consider this as a wrong interpretation.

RIP adressing is a special mode,
even the 05/0d defaults to RIP on certain instructions,

So any mov rax,[mem] should result in:

A1 xx xx xx xx xx xx xx xx ;absolute 64 bit

while only mov anyreg,[rip] should produce

8B "05/0D"... ;which then act with RIP-realative addressing

I think your way is the correct one.

__
wolfgang



.



Relevant Pages

  • Re: RIP relative adresses
    ... and others making absolute the default. ... mov rax, ... foo dq 0x0123456789ABCDEF ...
    (alt.lang.asm)
  • Re: References to symbols in functions?
    ... > I.e. it can't just jump to the address of the BAR function because BAR ... but at least the disassembly of #'foo is useful. ... ; E8: XOR ECX, ECX ... ; 27: MOV ECX, ...
    (comp.lang.lisp)
  • Re: c = foo(--a) + a; ?
    ... A compiler is allowed to notice that foo() and bar() return ... MOV x, 48 ... CALL _printf ...
    (comp.lang.c)
  • Re: RFC: RIP relative adresses
    ... and others making absolute the default. ... There is a common saying in computer science: ... (it seems a few other assemblers, including gas, do it this way). ... mov, rax ...
    (alt.lang.asm)
  • Re: NASM: section start address
    ... org 100h ... mov ax, section.foo.start ... times 10h nop ... section foo start=200h ...
    (comp.lang.asm.x86)