Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

powerpc-elf-as Assembly errors

258 views
Skip to first unread message

Larry Lindsey

unread,
Nov 10, 2003, 10:00:42 AM11/10/03
to
I am writing assembly code for a powerpc 603e core target processor, which
is believe is synonymous with G2. Here's the test code:

xor r0, r0, r0
lis r3, 0x0000
Loop:
addi r3, r3, 0x0001
b Loop

When I run that through the powerpc-elf assembler, I receive the following
errors:

woo2.s: Assembler messages:
woo2.s:1: Error: unsupported relocation type
woo2.s:1: Error: unsupported relocation type
woo2.s:1: Error: unsupported relocation type
woo2.s:2: Error: unsupported relocation type
woo2.s:4: Error: unsupported relocation type
woo2.s:4: Error: unsupported relocation type

I assume this has something to do with register names. What goes in place
of r0 for general purpose registers? So far, I haven't had any luck digging
through the info or man pages. Am I using the correct assembler?

Thanks for any help,

Larry Lindsey


Andy Sinclair

unread,
Nov 10, 2003, 11:35:09 AM11/10/03
to
Larry Lindsey wrote:
>I assume this has something to do with register names.
Indeed. You need to prepend the register name with '%'.
e.g.

cmplw %r1,%r2

Regards
Andy Sinclair

Rob Windgassen

unread,
Nov 10, 2003, 2:27:03 PM11/10/03
to
On Mon, 10 Nov 2003 10:00:42 -0500, Larry Lindsey wrote:

> I assume this has something to do with register names. What goes in place
> of r0 for general purpose registers? So far, I haven't had any luck digging
> through the info or man pages. Am I using the correct assembler?

you can define

#define r0 0
#define r3 3
etc.

When you build a gcc ppc cross compiler the file ppc-asm.h with these defines
(and more) will be placed in a compiler system header file directory,
It can be included in your assembly source by means of #include <ppc-asm.h>.

Rob Windgassen

42Bastian Schick

unread,
Nov 11, 2003, 7:48:52 AM11/11/03
to
On Mon, 10 Nov 2003 20:27:03 +0100, "Rob Windgassen"
<rwin...@xs-DIGIT-FOUR-all.nl> wrote:

>On Mon, 10 Nov 2003 10:00:42 -0500, Larry Lindsey wrote:
>
>> I assume this has something to do with register names. What goes in place
>> of r0 for general purpose registers? So far, I haven't had any luck digging
>> through the info or man pages. Am I using the correct assembler?
>
>you can define
>
>#define r0 0
>#define r3 3
>etc.

This way is dangerous, because the following two opcodes are correct,
but a little typo ...
Typed:
addi r4,r4,r5 => addi 4,4,5 (correct)
But wanted:
add r4,r4,r5 => add 4,4,5 (correct)


but using
#define r0 %r0
#define r1 %r1
...

should work as well.

---
42Bastian
Do not email to bast...@yahoo.com, it's a spam-only account :-)
Use <same-name>@epost.de instead !

Rob Windgassen

unread,
Nov 11, 2003, 5:47:55 PM11/11/03
to
On Tue, 11 Nov 2003 12:48:52 +0000, 42Bastian Schick wrote:

> This way is dangerous, because the following two opcodes are correct,
> but a little typo ...
> Typed:
> addi r4,r4,r5 => addi 4,4,5 (correct)
> But wanted:
> add r4,r4,r5 => add 4,4,5 (correct)
>
> but using
> #define r0 %r0
> #define r1 %r1

> should work as well.

You are right about the danger, but that won't go away with %r0, etc.
I just tried

foo:
add %r0,%r1,%r2
addi %r0,%r1,%r2

but that assembles without problem or warning (using binutils-2.14) into

00000000 <foo>:
0: 7c 01 12 14 add r0,r1,r2
4: 38 01 00 02 addi r0,r1,2


Rob Windgassen

42Bastian Schick

unread,
Nov 12, 2003, 2:03:54 AM11/12/03
to
>
>You are right about the danger, but that won't go away with %r0, etc.
>I just tried
>
>foo:
> add %r0,%r1,%r2
> addi %r0,%r1,%r2
>
>but that assembles without problem or warning (using binutils-2.14) into
>
>00000000 <foo>:
> 0: 7c 01 12 14 add r0,r1,r2
> 4: 38 01 00 02 addi r0,r1,2
>

Oh, damn, you just cut my safety net :(

(To be honest,I did not check it)

0 new messages