This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PowerPC gas/ immediate range checking?
- To: bgill at ibmoto dot com
- Subject: Re: PowerPC gas/ immediate range checking?
- From: Geoff Keating <geoffk at geoffk dot org>
- Date: Fri, 25 May 2001 13:40:10 -0700
- CC: binutils at sources dot redhat dot com
- References: <3B0EB97B.5F791DDD@ibmoto.com>
- Reply-to: Geoff Keating <geoffk at redhat dot com>
> Date: Fri, 25 May 2001 14:58:51 -0500
> From: Becky Gill <bgill@ibmoto.com>
> I have a question about gas on PowerPC. The assembly instruction
>
> addi r3,r3,0xdead
>
> Generates this warning:
>
> Error: operand out of range (000000000000beef not between -32768 and 32767)
>
> However, this immediate value is perfectly valid for the addi instruction. It
> looks as though gas is treating it as unsigned by default, filling in with
> zeroes, and then range checking that number. This results in an incorrect
> error, since the above instruction is valid.
>
> So, 2 questions:
>
> 1) Why is gas implemented as it is currently? Is this intentional?
> 2) Is there a way to get around this problem when hand-coding assembly?
0xdead is the 32-bit value 0x0000dead. You can't add this to a
register in a single instruction. Instead, you must do:
addis r3,r3,-1
addi r3,r3,0x10000-0xdead
If you really meant to add -0x2153, it's probably better to write that.
GAS performs this check mostly to catch machine-generated operands that
overflow, for instance
Lbar: addi r3,r3,Lfoo-Lbar
...
Lfoo:
or
li r3,CO_APIC_LEVEL
where it isn't obvious that the operand would overflow.
--
- Geoffrey Keating <geoffk@geoffk.org>