RFC: RIP relative adresses



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.


in my case, I had implemented it a little differently:
mov rax, [foo]
will access foo via an absolute address.

mov rax, [rip+foo]
does like the original (possibly counterintuitive in that 'foo' is relative
in this case, but with any other reg would be absolute).

(it seems a few other assemblers, including gas, do it this way).


I had considered merging this with my existing relative-addr scheme:
mov rax, [$foo]

which is like the above but simply implies rip (working like the above
primarily because there is no explicit base, and normally doing a raw-access
for a value relative to some ill-defined address is non-sensible).

an alternative would be to make RIP-relative addressing the default, and add
a special convention for absolute addresses, ie:
mov rax, [foo] ;defaults to RIP

mov rax, [#foo]
defaults to ABS (#, @, ... seem possible). likewise, I could overload '$'
here, but this is counterintuitive.


note: in my case addresses given explicitly would always be ABS, ie:
mov [0xB8000], rax
mov [0xB8008], rcx
mov [0xB8010], rdx


a web search seems to reveal that some assemblers make abs the default in
long mode, and others make rip the default.


just felt curious to know what others' thoughts/opinions on this issue were.



.