Motherboard Forums


Reply
Thread Tools Display Modes

PowerPC: Problem with some assembler opcodes

 
 
Gilles
Guest
Posts: n/a
 
      01-31-2008, 11:45 PM
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
 
Reply With Quote
 
 
 
 
42Bastian Schick
Guest
Posts: n/a
 
      02-01-2008, 09:43 AM
On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <(E-Mail Removed)> 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 (E-Mail Removed), it's a spam-only account :-)
Use <same-name>@monlynx.de instead !
 
Reply With Quote
 
 
 
 
Gilles
Guest
Posts: n/a
 
      02-01-2008, 11:08 PM
42Bastian Schick wrote:

> On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <(E-Mail Removed)> 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

 
Reply With Quote
 
Gilles
Guest
Posts: n/a
 
      02-05-2008, 08:06 PM
Gilles wrote:

> 42Bastian Schick wrote:
>
>> On Fri, 01 Feb 2008 00:45:50 +0100, Gilles <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
undocumented PIC16 opcodes bruno gavand Embedded 26 07-04-2007 10:01 PM
pic 16fx opcodes Account1 Embedded 0 03-14-2007 01:21 PM
documentation for PIC24x opcodes? Account1 Embedded 3 12-18-2006 04:03 AM
Undefined opcodes on AVR? Sheldon Simms Embedded 10 09-18-2003 02:17 AM
how different is pic assembler and avr assembler? Michael Embedded 3 08-14-2003 12:21 PM


All times are GMT. The time now is 02:44 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment