public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [gas] Unsigned arithmetic and %hi() operator
@ 2016-04-01 18:28 Orlando Arias
  2016-04-01 18:43 ` Orlando Arias
  0 siblings, 1 reply; 4+ messages in thread
From: Orlando Arias @ 2016-04-01 18:28 UTC (permalink / raw)
  To: binutils


[-- Attachment #1.1: Type: text/plain, Size: 1439 bytes --]

Greetings,

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.

Cheers,
Orlando.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gas] Unsigned arithmetic and %hi() operator
  2016-04-01 18:28 [gas] Unsigned arithmetic and %hi() operator Orlando Arias
@ 2016-04-01 18:43 ` Orlando Arias
  2016-04-05 13:59   ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Orlando Arias @ 2016-04-01 18:43 UTC (permalink / raw)
  To: binutils


[-- Attachment #1.1: Type: text/plain, Size: 1865 bytes --]

Greetings,

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

Both statements assemble in this case. Sorry for the confusion. The
larger statements fail to assemble. Thank you.

Cheers,
Orlando.

On 04/01/2016 02:31 PM, Orlando Arias wrote:
> Greetings,
> 
> 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.
> 
> Cheers,
> Orlando.
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gas] Unsigned arithmetic and %hi() operator
  2016-04-01 18:43 ` Orlando Arias
@ 2016-04-05 13:59   ` Nick Clifton
  2016-04-05 14:15     ` Orlando Arias
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2016-04-05 13:59 UTC (permalink / raw)
  To: Orlando Arias, binutils

Hi Orlando,

> the error "Error: missing ')'
>
> sethi %hi(((((0x40000000U + 0x40000000U) - 160)-(8192U-160))-32U)), %fp
> or %g0, %lo(((((0x40000000U +0x40000000U) - 160)-(8192U-160))-32U)), %fp

This is definitely a bug.

Please could you file a bug report here so that we can start looking into it ?

  https://sourceware.org/bugzilla/

Cheers
  Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gas] Unsigned arithmetic and %hi() operator
  2016-04-05 13:59   ` Nick Clifton
@ 2016-04-05 14:15     ` Orlando Arias
  0 siblings, 0 replies; 4+ messages in thread
From: Orlando Arias @ 2016-04-05 14:15 UTC (permalink / raw)
  To: Nick Clifton, binutils


[-- Attachment #1.1: Type: text/plain, Size: 601 bytes --]

Greetings,

Bug report has been filed [1]. Thank you for your time.

Cheers,
Orlando.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=19910

On 04/05/2016 09:58 AM, Nick Clifton wrote:
> Hi Orlando,
> 
>> the error "Error: missing ')'
>>
>> sethi %hi(((((0x40000000U + 0x40000000U) - 160)-(8192U-160))-32U)), %fp
>> or %g0, %lo(((((0x40000000U +0x40000000U) - 160)-(8192U-160))-32U)), %fp
> 
> This is definitely a bug.
> 
> Please could you file a bug report here so that we can start looking into it ?
> 
>   https://sourceware.org/bugzilla/
> 
> Cheers
>   Nick
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-05 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 18:28 [gas] Unsigned arithmetic and %hi() operator Orlando Arias
2016-04-01 18:43 ` Orlando Arias
2016-04-05 13:59   ` Nick Clifton
2016-04-05 14:15     ` Orlando Arias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).