rv64: bug in encoding of bge?
Paulo Matos
pmatos@linki.tools
Thu Jan 10 07:03:00 GMT 2019
On 09/01/2019 21:48, Jim Wilson wrote:
> On 1/9/19 6:10 AM, Paulo Matos wrote:
>> 0000000000000000 <foo>:
>>    0:  00c5d063               bge    a1,a2,0 <foo>
>>    4:  feb65ee3               bge    a2,a1,0 <foo>
>>    8:  fec5fce3               bgeu   a1,a2,0 <foo>
>>    c:  feb67ae3               bgeu   a2,a1,0 <foo>
>>
>>
>> The first encoding looks fine but the first byte of the others (0xfe)
>> just don't look correct. For example, for the second instruction I would
>> have expected:
>> Â Â Â 4:Â Â 00b65063Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bge a2,a1,0
>
> The upper bits hold part of the offset. The first instruction branches
> to itself so the offset is 0. The following branches go backwards to
> address 0, so the offset is negative. That causes the upper 7 bits to
> all be 1.
>
Of course, I was totally confused because the dump shows
bge a2,a1,0
and my eyes were glossing over the <foo> at the end of each line.
Therefore I expected that all instructions should be looping to themselves.
But the original code has them all looping back to foo.
Got it, thanks.
--
Paulo Matos
More information about the Binutils
mailing list