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


----Original Message----
>From: Alan Modra
>Sent: 17 September 2005 15:15

> 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,
> 
>>  .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 was about to write this as well.  I think it would be bizarre if
changing the value of one went back and recalculated two and three.  If I
wanted the value to change in that way, I'd do it by using a #define macro
and preprocessing my source, like this:


#define two (2*one)
	.equ one, 1
      >>>>>>>>see below<<<<<

.data	
	.byte	one
	.byte	two

.equ	one, -1
	.byte	one
	.byte	two


  You could then decide whether or not you wanted something to be
recalculated by whether you made it a macro or a .equ, so 'three' could be
either an equ or a macro according to whether you wanted it to be
recalculated or not.  This does have the side effect that you wouldn't have
a 'two' symbol in the output source, but how useful would it actually be to
have just one of the (perhaps many) values a symbol has been assigned at
different stages of the assembly? 

> I don't think taking a snapshot of the expression is correct.  It's
> obviously wrong for an expresion that is undefined at the point where it
> is used, for example:
> 
> str1:
>  .byte len
>  .ascii "pascal style string"
> len = . - str1 - 1

  Hang on though, the forward reference here isn't in the .equ - it's in the
.byte.  From the title of the thread I thought this would only change the
behaviour of .equ (which in this case is a backward reference)?


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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