This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: arm-elf-as truncates branch offsets w/o warning
- To: alan at SPRI dot Levels dot UniSA dot Edu dot Au
- Subject: Re: arm-elf-as truncates branch offsets w/o warning
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Fri, 17 Mar 2000 10:35:37 -0800
- CC: grante at visi dot com, scottb at netwinder dot org, binutils at sourceware dot cygnus dot com
Hi Alan,
: > + /* Sign-extend a 24-bit number. */
: > + #define SEXT24(x) ((((x) & 0xffffff) ^ (~ 0x7fffff)) + 0x800000)
: > +
:
: Hi Nick,
: That looks wrong. Don't you mean
:
: #define SEXT24(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000)
: ^
: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>^
No, the plus and the inversion are right.
Here are a couple of examples:
x: 0xf7f00000 x: 0xf7700000
& 0x00ffffff & 0x00ffffff
------------- --------------
0x00f00000 0x00700000
^ 0xff800000 ^ 0xff800000
------------- --------------
0xff700000 0xfff00000
+ 0x00800000 + 0x00800000
------------- --------------
0xfff00000 0x00700000
This method works regardless of the size of the host's word, (well
assuming that it is at least 32 bits anyway).
Cheers
Nick