This is the mail archive of the 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]

[gas] Unsigned arithmetic and %hi() operator


I have been dealing with this issue for a while now and I believe to
have narrowed down the cause to an issue with the %hi() operator. I am
working with the sparc-leon3-linux target in gas versions 2.26.20160125
and 2.23.

In the following assembly statements, the numbers come from macro
expansions by the C preprocessor. These statements fail to assemble with
the error "Error: missing ')'

sethi %hi(((((0x40000000U + 0x40000000U) - 160)-(8192U-160))-32U)), %fp
or %g0, %lo(((((0x40000000U +0x40000000U) - 160)-(8192U-160))-32U)), %fp

However, the following assembles just fine:

sethi %hi(((((0x40000000 + 0x40000000) - 160)-(8192-160))-32)), %fp
or %g0, %lo(((((0x40000000 +0x40000000) - 160)-(8192-160))-32)), %fp

The statements are exactly the same, except that the numbers are now
treated as signed.

I have further simplified this to:

sethi %hi(0x40000000U + 0x40000000U), %fp	# does not assemble
sethi %hi(0x40000000 + 0x40000000), %fp		# assembles

The same error behaviour can be obtained with the 'set' pseudoinstruction.

I could leave the U out of the macro definitions, but then gcc complains
of overflows in the macros (which is not a show stopper, but it is ugly,
as these macros get used repeatedly throughout the codebase).

Have I overlooked something in the documentation/bugtracker or is this a
parsing bug in gas?

Thank you for your time.


Attachment: signature.asc
Description: OpenPGP digital signature

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