Re: RFC: RIP relative adresses



On Apr 27, 2:24 pm, "cr88192" <cr88...@xxxxxxxxxxxxxxxxxx> 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.

There is a common saying in computer science: "Optimize for the most
common case".
Now just what "optimal" means in this case is a good question. If
you're trying to minimize typing, for example, I'd go with the mode
that is used most often as the one that get the plain ID.

Suppose you're trying to optimize readability. Given that all the
existing code uses an unadorned label as an absolute address, it makes
sense to keep that scheme for 64-bit code, so that people won't get
confused when switching between 32-bit code and 64-bit code.


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

Be careful about using Gas (AT&T syntax?) as your model. Often, I've
found that syntactical additions to Gas have been motivated more by a
desire to make the changes to the assembler easy rather than being
based on some global overriding principle.


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

If you go this route, I would recommend "@". "AT <address>" sounds
more like an absolute address to me than the other alternatives.



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

No. I'd use whatever scheme you decide for symbolic addresses. If the
default becomes RIP, then require the "@" (or whatever) in front of
the numbers. Consistency is very important. Then again, that's also an
argument for making absolute address the default anyway (as it's more
consistent with the 32-bit modes).

hLater,
Randy Hyde

.