Hi Sgan,
Thank you very much for finding this issue in the compiler. You are correct that there is a bug here, __builtin_ldbio() should be translating to a ldbio instruction, not a ldhio. This issue will be fixed for the next release of the compiler. If this is causing you a particular issue, I recommend either using __builtin_ldbuio() and sign extending it, or using extended assembly statements.
That said, there is a related conversation elsewhere on the forum that you may be interested in.
http://www.niosforum.com/forum/index.php?a...ct=st&f=2&t=435 (
http://www.niosforum.com/forum/index.php?act=st&f=2&t=435)
This discusses some of the other issues that you point out here, as even if this bug did not exist, the generated assembly would be:
movi r3, 4096
ldbio r2, 0(r3)
slli r2, r2, 24
srai r2, r2, 24
ret
in this case as __builtin_ldXio returns ints.
Jonah