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: macro's and local variables


On 10/19/2012 01:21 AM, Jan Beulich wrote:

> I don't follow - an assembler is an assembler, not a C compiler.

Yet even an assembler can use the C syntax and semantics for *expressions*.
It's useful, widely understood, easy to document, easy to implement,
easy to test and maintain.  The omitted operators truly are missed
by writers of assembly code.

For instance: http://lists.libav.org/pipermail/libav-devel/2012-August/032685.html
(and its ancestors):
-----
>> -#define TMPSIZE \size * (8 - 8*(\size > 4) + \ytaps - 1)
>> +/* True relational expressions have the value -1 in the GNU assembler,
>> +   +1 in Apple's. */
>> +#ifdef __APPLE__
>> +#   define TMPSIZE \size * (8 + 8*(\size > 4) + \ytaps - 1)
>> +#else
>> +#   define TMPSIZE \size * (8 - 8*(\size > 4) + \ytaps - 1)
>> +#endif

> If the assembler evaluates conditional expressions
> then this can be unified, removing the configuration-dependent "#if":
> 
> #define TMPSIZE \size * (8 + ((\size > 4) ? 8 : 0) + \ytaps - 1)

It doesn't.

!!(\size > 4) would work if GNU as had the unary ! operator.
It doesn't.

(1 && (\size > 4)) would work if Apple's assembler had the && operator.
It doesn't.

((\size > 4) * (\size > 4)) might work, but I'm not at all convinced it
is any better.
-----

In the worst case, let text which appears between '\007' (control-G)
characters be interpreted as a C expression.

-- 


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