EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

PowerPC: Problem with some assembler opcodes

Started by Gilles January 31, 2008
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
On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <Idont@like.spam> 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 bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@monlynx.de instead !
42Bastian Schick wrote:

> On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <Idont@like.spam> 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 wrote:

> 42Bastian Schick wrote: > >> On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <Idont@like.spam> 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

The 2024 Embedded Online Conference