ill effect of <register>+<constant>

Dave Korn dave.korn@artimi.com
Fri Sep 21 16:34:00 GMT 2007


On 21 September 2007 17:21, Andreas Schwab wrote:

> "Dave Korn" <dave.korn@artimi.com> writes:
> 
>> On 21 September 2007 16:13, Andreas Schwab wrote:
>> 
>>> "Jan Beulich" <jbeulich@novell.com> writes:
>>> 
>>>> To me, adding a constant to a register and getting a different register
>>>> is all but a useful feature (maybe it is in e.g. PPC semantics where
>>>> registers can be represented by plain numbers). But beyond that,
>>> 
>>> That's the main feature.  Registers _are_ plain numbers.
>> 
>>   I can see where that's useful on pcc, but on x86, the registers aren't
>> equipotent; it makes no sense at all to me.
> 
> But it does no harm either.  

  Well, to me, turning an instruction that refers to edi and edx into one that
references esi is somewhat in accord with the principle of *most* surprise!

> So why cripple the assembler?  

  I don't see how removing an unused and non-useful feature would really count
as "crippling".  I'm not suggesting it should be disabled for ppc, but for
x86, really .... what could conceivably be the use?

> If you want text replacement then use a text macro.

  Yeh, that's a reasonable argument.  I think what I want most of all would be
for it to fold

  mov eax,[base+idx*4] 
    -> mov eax,[edx+4+(edi-1)*4] 
        -> mov eax,[edx+4+edi*4-1*4]
            -> mov eax,[edx+edi*4]

but I guess that's a different story altogether.

  Perhaps in this case the assembler could issue a warning that "Adding
integers to registers may not do what you expect"?

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



More information about the Binutils mailing list