bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/19910] Unsigned arithmetic and %hi()/%low() operators


From: orlandoarias at gmail dot com
Subject: [Bug gas/19910] Unsigned arithmetic and %hi()/%low() operators
Date: Tue, 05 Apr 2016 14:20:15 +0000

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

--- Comment #4 from Orlando Arias <orlandoarias at gmail dot com> ---
(In reply to Nick Clifton from comment #3)
> Created attachment 9154 [details]
> Proposed patch
> 
> Hi Orlando,
> 
>   Please try this patch, which should improve the error message somewhat.
> 
> Cheers
>   Nick

Greetings,

The patch works as expected, making the error much more clear.

$ cat assembler.S 
        sethi %hi(0x4000U), %g1
        or %g0, %lo(0x4000U + 0x4000U), %g1
        or %g0, %lo((0x4000U + 0x4000U)), %g1

$ sparc-leon3-linux-as -c assembler.S 
assembler.S: Assembler messages:
assembler.S:3: Error: found 'U', expected: ')'

However, if U as a suffix is not supported, the assembler should catch line 2
of the testcase as invalid as well. The assembler, however, parses it
incorrectly:

$ cat assembler.S 
        sethi %hi(0x4000U), %g1
        or %g0, %lo(0x4000U + 0x4000U), %g1
$ sparc-leon3-linux-as -c assembler.S
$ sparc-leon3-linux-objdump -S a.out 

a.out:     file format elf32-sparc


Disassembly of section .text:

00000000 <.text>:
   0:   03 00 00 10     sethi  %hi(0x4000), %g1
   4:   82 10 20 00     clr  %g1

Manually expanding the pseudoinstruction, we see that it is actually doing:

or %g0, 0, %g1

instead of throwing an error. Naturally, the immediate constant is incorrectly
computed. Thank you for looking into this.

Cheers,
Orlando.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]