1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

PowerPC: Problem with some assembler opcodes

Discussion in 'Embedded' started by Gilles, Jan 31, 2008.

  1. Gilles

    Gilles Guest

    Hello all, I'm using the powerpc-eabispe gcc version 3.4.4 and I want
    to initialize the decrenenter with the following code:

    #include "mpc5500_spr.h"

    union SPR_TCRVAL my_SPR_TCRVAL;
    union SPR_HID0VAL my_SPR_HID0VAL;

    /* Load initial DEC value */
    asm volatile ("mtdec %[DEC]"::[DEC]"r"(configCPU_CLOCK_HZ /
    configTICK_RATE_HZ));
    /* Load the same value into the reload register */
    asm volatile ("mtdecar %[DECAR]"::[DECAR]"r"(configCPU_CLOCK_HZ /
    configTICK_RATE_HZ));
    /* Enable decrementer interrupt */
    my_SPR_TCRVAL.B.DIE = 1;
    /* Auto-reload enable */
    my_SPR_TCRVAL.B.ARE = 1;
    asm volatile ("mttcr %[TCR]"::[TCR]"r"(my_SPR_TCRVAL));
    /* Time base: 0 = processor clock, 1 = p_tbclk */
    my_SPR_HID0VAL.B.SEL_TBCLK = 0;
    /* Enable the time base and decrementer */
    my_SPR_HID0VAL.B.TBEN = 1;
    asm volatile ("mthid0 %[HID0]"::[HID0]"r"(my_SPR_HID0VAL));

    The resulting error message is: Error: Unrecognized opcode: `mthid0'

    than I tried the following:

    asm volatile ("mtspr %[SPRHID0],
    %[HID0]"::[SPRHID0]"i"(SPR_HID0),[HID0]"r"(my_SPR_HID0VAL));

    This compiles but the wornf code is generated, the dump of the elf-file:

    asm volatile ("mtspr %[SPRHID0],
    %[HID0]"::[SPRHID0]"r"(SPR_HID0),[HID0]"r"(my_SPR_HID0VAL));
    a920: 39 20 03 f0 li r9,1008
    a924: 80 1f 00 0c lwz r0,12(r31)
    a928: 7c 09 03 a6 mtctr r0

    Finally I tried it with the following line od code:

    asm volatile ("mtspr 1008, r0");
    a920: 7c 10 fb a6 mtdbsr r0

    Why is mthid0 unkown and why is the compiler/assember generating the wrong
    code?
    How can I write into the HID0 Register with the gnu compiler?

    Regards, Gilles
     
    Gilles, Jan 31, 2008
    #1
    1. Advertising

  2. On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <> wrote:

    >Hello all, I'm using the powerpc-eabispe gcc version 3.4.4 and I want
    >to initialize the decrenenter with the following code:


    gcc is not imported. The assembler (binutils) counts.

    >asm volatile ("mthid0 %[HID0]"::[HID0]"r"(my_SPR_HID0VAL));


    This is a 5554 specific registers. You might try using -mcpu=8540
    in the commanline.

    >asm volatile ("mtspr 1008, r0");
    > a920: 7c 10 fb a6 mtdbsr r0


    Did you lookup the real opcode ? Don't trust the disassembler here.

    I use 3.4.4 gcc and 2.16.1 binutils and have no problem writing hid0
    the above way.


    --
    42Bastian
    Do not email to , it's a spam-only account :)
    Use <same-name>@monlynx.de instead !
     
    42Bastian Schick, Feb 1, 2008
    #2
    1. Advertising

  3. Gilles

    Gilles Guest

    42Bastian Schick wrote:

    > On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <> wrote:
    >
    >>Hello all, I'm using the powerpc-eabispe gcc version 3.4.4 and I want
    >>to initialize the decrenenter with the following code:

    >
    > gcc is not imported. The assembler (binutils) counts.
    >
    >>asm volatile ("mthid0 %[HID0]"::[HID0]"r"(my_SPR_HID0VAL));

    >
    > This is a 5554 specific registers. You might try using -mcpu=8540
    > in the commanline.
    >
    >>asm volatile ("mtspr 1008, r0");
    >> a920: 7c 10 fb a6 mtdbsr r0

    >
    > Did you lookup the real opcode ? Don't trust the disassembler here.


    Until now I've always made an object dump from the elf and never looked to
    the real opcodes. What is the best procedure to do that?

    >
    > I use 3.4.4 gcc and 2.16.1 binutils and have no problem writing hid0
    > the above way.
    >
    >

    My version of the Binutils is 2.15.91, the one that was on the cd that came
    with the P&E NEXUS.
    Is there a place where I can download ready to use GCC/Binutils/Newlib for
    the MPC55xx architecture?

    Regards, Gilles
     
    Gilles, Feb 1, 2008
    #3
  4. Gilles

    Gilles Guest

    Gilles wrote:

    > 42Bastian Schick wrote:
    >
    >> On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <> wrote:
    >>
    >>>Hello all, I'm using the powerpc-eabispe gcc version 3.4.4 and I want
    >>>to initialize the decrenenter with the following code:

    >>
    >> gcc is not imported. The assembler (binutils) counts.
    >>
    >>>asm volatile ("mthid0 %[HID0]"::[HID0]"r"(my_SPR_HID0VAL));

    >>
    >> This is a 5554 specific registers. You might try using -mcpu=8540
    >> in the commanline.
    >>
    >>>asm volatile ("mtspr 1008, r0");
    >>> a920: 7c 10 fb a6 mtdbsr r0

    >>
    >> Did you lookup the real opcode ? Don't trust the disassembler here.

    >
    > Until now I've always made an object dump from the elf and never looked to
    > the real opcodes. What is the best procedure to do that?
    >


    After analyzing the generated hex code: "7c 10 fb a6" I can conclude that
    the code itself is correct and that it must be a problem of the
    disassembler.

    Do I have to specify a CPU when I'm analyzing the elf with
    powerpc-eabispe-objdump?

    >>
    >> I use 3.4.4 gcc and 2.16.1 binutils and have no problem writing hid0
    >> the above way.
    >>
    >>

    > My version of the Binutils is 2.15.91, the one that was on the cd that
    > came with the P&E NEXUS.
    > Is there a place where I can download ready to use GCC/Binutils/Newlib for
    > the MPC55xx architecture?
    >
    > Regards, Gilles


    I'm still looking for a more recent version of the GCC/Binutils/Newlib.

    Regards, Gilles
     
    Gilles, Feb 5, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael
    Replies:
    3
    Views:
    600
  2. Sheldon Simms

    Undefined opcodes on AVR?

    Sheldon Simms, Sep 5, 2003, in forum: Embedded
    Replies:
    10
    Views:
    1,509
    Brian Dean
    Sep 18, 2003
  3. David R Brooks

    Inline assembler on PowerPC

    David R Brooks, Jun 13, 2005, in forum: Embedded
    Replies:
    17
    Views:
    471
    R Adsett
    Jun 18, 2005
  4. Account1

    documentation for PIC24x opcodes?

    Account1, Dec 16, 2006, in forum: Embedded
    Replies:
    3
    Views:
    775
    Iain McCracken
    Dec 18, 2006
  5. Account1

    pic 16fx opcodes

    Account1, Mar 14, 2007, in forum: Embedded
    Replies:
    0
    Views:
    508
    Account1
    Mar 14, 2007
Loading...

Share This Page