[Dwarf-Discuss] DWARF piece questions
eager at eagercon.com
Thu Jan 26 17:07:44 PST 2017
On 01/26/2017 11:17 AM, Andreas Arnez wrote:
> On Wed, Jan 25 2017, Andrew Cagney wrote:
>>> Also, I suggest to avoid the terms "left" and "right", since I
>>> encountered various occasions where they caused more confusion than they
>>> helped. And the term "most significant" can not generally be applied to
>>> registers either, so in this case I'd prefer something like "located in
>>> the lowest-addressed bytes of the register when stored in memory".
>> I've not found this to be true.
> Really? I usually refer to lower- and higher-addressed memory units by
> "left" and "right", respectively. However, all diagrams in the Intel 64
> and IA-32 architectures have this reversed and show lower addresses
> below/right and higher addresses above/left. Similarly, when referring
> to the bytes in a register I'd call the lower- and higher-addressed
> bytes (in natural memory representation) "left" and "right",
> respectively. But at least for integer registers some people call the
> most significant bytes "left", independently from byte ordering. I had
> a lengthy discussion with Jian Xu, where one of our misunderstandings
> was centered around the definition of "left" and "right". How do you
> interpret these terms?
The terms "most-significant bit," "least-significant bit," and corresponding
terminology using bytes seems to be unambiguous and well understood.
On the other hand, using bit or byte numbering, or left or right, seem to
depend on who is drawing a diagram and where they start numbering. There
is more consistency in description among big-endian architectures than among
little-endian, but there's clearly no hard and fast rule. Registers are not
physical constructs which have an up, down, left, right, front or back.
(At least, in the abstract sense, ignoring physical implementation.)
I've used left or right to refer to register or memory values, usually in
a colloquial fashion, especially when referring to the printed value of a
register or memory value. Whether left means most-significant or least-
significant, or lower address or higher, depends on how the values are printed.
I don't understand the assertion that "most significant" can not be applied
to registers. In the case where a register contains a single value, this
appears to be unambiguous. When a register contains multiple values (some
architectures support 2 16-bit values in a 32-bit register, for example), then
additional clarification may be needed. The ABI provides this, usually. The
situation where a single value is split across two registers is similar. When
discussing compound values (such as floating point) it is common to say that
the sign bit is in the most-significant bit of the register, without ambiguity.
So, to answer your question "how do I interpret left and right", in a DWARF
context, I don't, since they are not used. When there is a whiteboard in
front of me, I can point to which ever byte/bit/number is on the left or right.
Michael Eager eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
More information about the Dwarf-Discuss