powerpc-eabi assembler

Pete Popov ppopov@redcreek.com
Sun Dec 19 19:24:00 GMT 1999


>Ian Lance Taylor wrote:
>>
>>    Date: Tue, 14 Dec 1999 20:58:16 -0800
>>    From: Peter Popov <ppopov@redcreek.com>
>>
>>    I'm using a powerpc-eabi compiler which I built from
>>    gcc-2.92.2 and binutils-2.9.1.  The assembler chokes on
>>    instructions like this one:
>>
>>    li r5, 0xfffe
>>
>>    initads.s:194: Error: operand out of range (65534 not between -32768 and 32767)
>>
>>    It complains that the operand is out of range, when in fact,
>>    if should just translate the 0xfffe t0 -2.   Does anyone know if
>>    this is an assembler bug, or is it a feature?
>>
>> It's a feature.  You're asking the assembler to load 0xfffe into r5.
>> That can't be done in one li instruction.  You can load 0xfffffffe,
>> but you can't load 0x0000fffe.

The instruction "li r5,0xfffe" should, in fact, load 0xfffffffe in
register r5, not 0x0000fffe.  The syntax is "li r5,SIMM"; the signed
bit is extended so you should end up with 0xfffffffe in r5.
 
 >> Did gcc generate that instruction?
  
  >No, it's in an assembly file I got from Motorola's web site.
  >The file was assembled with the Diab Data assembler; I tried that
  >and it worked (the Diab Data assembler generates :  "li  r5,-2"
  >from the "li r5, 0xfffe"), which is why I thought it was a bug.
   
   After some further analysis, I'm pretty convinced this is a gnu assembler
   bug, or a really bad limitation.  The instruction "li rD, value" is just
   a simplified mnemonic, equivalent to "addi rD,0,value".  The "addi" instruction,
   in turn, is defined as:  "addi rD,rA,SIMM", where SIMM is a 16 bit signed 
   integer.  Thus, "addi r5,0,0xfffe" should be a perfectly legal instruction,
   and equivalent to "addi r5,0,-2". The gnu assembler accepts the latter, but
   not the former.  The Diab Data assembler, on the other hand, accepts both
   formats and generates the same code.

   If choking on "li r5,0xfffe" is truly a feature, how would you load
   0xfffffffe in a register in one single instruction?  Doing so (loading
   0xfffffffe in a register in one instruction) is definitely possible, but
   not as long as the assembler doesn't accept 0xfffe as the equivalent of "-2".
   It forces you to manually convert negative numbers to decimal, which just
   doesn't make any sense.

   Anyone else agree this is a bad feature or a bug?

   Pete

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list