Crosscompiling trouble - Powerpc

This is a discussion on Crosscompiling trouble - Powerpc ; Hi all... I'm trying to crosscompile some code for a ppc403 and I'm getting problems at the beginning... The problem is not with the compiler, just the assembler (GNU as). I'm trying to assemble some elementary code like this one: ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Crosscompiling trouble

  1. Crosscompiling trouble

    Hi all...

    I'm trying to crosscompile some code for a ppc403 and I'm getting problems
    at the beginning...
    The problem is not with the compiler, just the assembler (GNU as).
    I'm trying to assemble some elementary code like this one:
    li %r3, 0xFFFF
    and I always get the same error:
    "fast_init.s:96: Error: operand out of range (65535 not between -32768 and
    32767)"
    In this case, the offending line is the line number 96, but I get the error
    in every "li" opcode.
    The funny thing is that if the opcode is "lis", there are no errors...
    Maybe It's a syntax mistake, but I can't find any doc about the syntax for
    ppc arch.
    The "as" version is 2.15, and the command that I use to assemble is
    "powerpc-linux-as -o fast_init.o -m403 fast_init.s"
    Any clue?

    Thanks in advance.

    Fernando Pena López.




  2. Re: Crosscompiling trouble

    On Thu, 09 Feb 2006 13:34:30 +0100, Fernando Pena López wrote:

    > Hi all...
    >
    > I'm trying to crosscompile some code for a ppc403 and I'm getting problems
    > at the beginning...
    > The problem is not with the compiler, just the assembler (GNU as). I'm
    > trying to assemble some elementary code like this one:
    > li %r3, 0xFFFF
    > and I always get the same error:
    > "fast_init.s:96: Error: operand out of range (65535 not between -32768 and
    > 32767)"
    > In this case, the offending line is the line number 96, but I get the
    > error in every "li" opcode.
    > The funny thing is that if the opcode is "lis", there are no errors...
    > Maybe It's a syntax mistake, but I can't find any doc about the syntax for
    > ppc arch.
    > The "as" version is 2.15, and the command that I use to assemble is
    > "powerpc-linux-as -o fast_init.o -m403 fast_init.s" Any clue?


    li is a shortcut for addi rD, 0, value
    and lis for addis rD, 0, value
    add takes signed operands.
    addi & addis sign extend their immediate operand to 32 bits.
    When using addi, you need to give a signed operand because
    0xFFFF extended to 32 bits is 0xFFFF if unsigned and 0xFFFFFFFF if
    signed.
    Then, you've got to use li %r3, 0xFFFFFFFF
    You don't have this constraint when using lis on 32 bits PowerPC
    architecture, as the immediate value is shifted left _before_ been
    extended to 32 bits. Then, the result is the same when using signed or
    unsigned values.
    But the constraint will (should ?) come back if compiling for a 64 bits
    PowerPC machine because the constant need to be signed extended from
    (value << 16) to a signed 64 bits constant.

    Hope this helps...


  3. Re: Crosscompiling trouble

    You said:

    >
    > li is a shortcut for addi rD, 0, value
    > and lis for addis rD, 0, value
    > add takes signed operands.
    > addi & addis sign extend their immediate operand to 32 bits.
    > When using addi, you need to give a signed operand because
    > 0xFFFF extended to 32 bits is 0xFFFF if unsigned and 0xFFFFFFFF if
    > signed.
    > Then, you've got to use li %r3, 0xFFFFFFFF
    > You don't have this constraint when using lis on 32 bits PowerPC
    > architecture, as the immediate value is shifted left _before_ been
    > extended to 32 bits. Then, the result is the same when using signed or
    > unsigned values.
    > But the constraint will (should ?) come back if compiling for a 64 bits
    > PowerPC machine because the constant need to be signed extended from
    > (value << 16) to a signed 64 bits constant.
    >
    > Hope this helps...
    >


    Hmm... Ok, now I understand.
    Maybe I have to rewrite some parts of my code :P

    Thanks a lot.



  4. Re: Crosscompiling trouble


    You said:

    >
    > li is a shortcut for addi rD, 0, value
    > and lis for addis rD, 0, value
    > add takes signed operands.
    > addi & addis sign extend their immediate operand to 32 bits.
    > When using addi, you need to give a signed operand because
    > 0xFFFF extended to 32 bits is 0xFFFF if unsigned and 0xFFFFFFFF if
    > signed.
    > Then, you've got to use li %r3, 0xFFFFFFFF
    > You don't have this constraint when using lis on 32 bits PowerPC
    > architecture, as the immediate value is shifted left _before_ been
    > extended to 32 bits. Then, the result is the same when using signed or
    > unsigned values.
    > But the constraint will (should ?) come back if compiling for a 64 bits
    > PowerPC machine because the constant need to be signed extended from
    > (value << 16) to a signed 64 bits constant.
    >
    > Hope this helps...
    >


    Ok, I can understand it, but, if I'm right, this error only happens if I try
    to
    compile/assemble for ppc64, but I'm compiling for a ppc32 (I use the -m403
    modifier,
    that means that it should compile for a ppc 403, 32 bit core).
    Am I forgetting something?

    Thanks.



  5. Re: Crosscompiling trouble

    On Fri, 10 Feb 2006 10:49:59 +0100, Fernando Pena López wrote:

    >
    > You said:
    >
    >
    >> li is a shortcut for addi rD, 0, value and lis for addis rD, 0, value
    >> add takes signed operands.
    >> addi & addis sign extend their immediate operand to 32 bits. When using
    >> addi, you need to give a signed operand because 0xFFFF extended to 32
    >> bits is 0xFFFF if unsigned and 0xFFFFFFFF if signed.
    >> Then, you've got to use li %r3, 0xFFFFFFFF You don't have this
    >> constraint when using lis on 32 bits PowerPC architecture, as the
    >> immediate value is shifted left _before_ been extended to 32 bits. Then,
    >> the result is the same when using signed or unsigned values.
    >> But the constraint will (should ?) come back if compiling for a 64 bits
    >> PowerPC machine because the constant need to be signed extended from
    >> (value << 16) to a signed 64 bits constant.
    >>
    >> Hope this helps...
    >>
    >>

    > Ok, I can understand it, but, if I'm right, this error only happens if I
    > try to
    > compile/assemble for ppc64, but I'm compiling for a ppc32 (I use the -m403
    > modifier,
    > that means that it should compile for a ppc 403, 32 bit core). Am I
    > forgetting something?
    >


    The error should happen in 32 bits and 64 bits cases when using li:
    the PowerPC will sign extend a 16 bits constant to 32 or 64 bits.
    Then the constant really need to be signed.
    The difference between 32 and 64 bits architecture may only appear when
    using lis because on a 32 bit CPU, the sign extension of a 32 bits
    constant do nothing.


+ Reply to Thread