This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: forward references in equates


>>> Alan Modra <amodra@bigpond.net.au> 19.09.05 16:22:35 >>>
>On Mon, Sep 19, 2005 at 09:35:51AM +0200, Jan Beulich wrote:
>> >>> Alan Modra <amodra@bigpond.net.au> 17.09.05 16:14:46 >>>
>> >On Fri, Sep 16, 2005 at 01:58:19PM +0200, Jan Beulich wrote:
>> >> 
>> >>  .equiv two, 2*one
>> >>  .equ one, 1
>> >>  .equiv three, 3*one
>> >> 
>> >>  .data
>> >> 
>> >> 	.byte	one
>> >> 	.byte	two
>> >> 	.byte	three
>> >
>> >I'd be reasonably confortable if gas gave 1, 2, 3 for the above,
>> 
>> That'd be my expectation, too.
>> 
>> >>  .equ one, -1
>> >> 	.byte	one
>> >> 	.byte	two
>> >> 	.byte	three
>> >
>> >but what should these be?  I'd be inclined to say -1, 2, 3.  Are
you
>> >proposing that the last three values be -1, -2, -3?  That would be
>> >changing the meaning of .equiv, I think.
>> 
>> I'm not as determined about the third value, but the second value
>> should certainly be -2 (as the definition of two is clearly using a
>> forward reference).
>
>I don't agree that it follows from the definition of "two" being a
>forward reference to "one" that the evaluation of "two" *must* always
be
>"2*one".  .set and its variations define symbols, not functions or
>macros, so there are other quite reasonable possibilities.  I'm not
>saying that expecting -2 is unreasonable, in fact that might be the
most
>useful result.  What do other assemblers give for your testcase?

As indicated in the original mail, MASM (x86) and ias (ia64) both
behave the way described (generating 2 for two first reference to two
and -2 for the second, while producing 3 for both references to three).
ias, with its == operator, additionally would even produce different
values with

one=1
four==4
.byte four
one=-1
.byte four

(i.e. when, in source order, there aren't any forward references).

At present I don't have any other assemblers to check against.

Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]