[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: some basic problems with ppc assembler



On Wed, 25 Jun 2003, Oliver Ripka wrote:
> I try to understand some ppc-assembler-code but it is harder than
> x86 to me because of the missing documentation. I have a big reference
> from ibm here. And some websites which deal with this topic.

There's lots of documentation about PPC assembler on the Motorola website, too.

> .LC0:				//I guess this means .LC0 
>         .string "Hello World"   //is a global string
>         .globl main		//within the main label. 
> 
>         .type   main, @function //whats that for?
> main:
>         stwu 1,-32(1)           //I do not understand this.

Store Word Unsigned, i.e. save r1 to address r1-32.

>         mflr 0			//Does this 

Move From LR (Link Register). LR is used to store the return address for a
subroutine, i.e. save the return address in r0.

I.e. move LR to r0.

>         stw 31,28(1)		//setup some 

Store r31 to address r1+28.

>         stw 0,36(1)             //GPRs for the

Store r0 to address r1+36

>         mr 31,1			//begin of the code??

Move r1 to r31.

>         lis 9,.LC0@ha           //this is
>         la 3,.LC0@l(9)		//fine

OK

>         crxor 6,6,6		//this clears the contend of crb6 right?
>         bl printf		//mhh..

Branch with Link Register, i.e. subroutine call

>         li 0,0			//set the GPR0 to completly to zeros
>         mr 3,0			//why that?? since 0 OR 0 is 0 it just
> 				//moves GPR0 to GRP3, right?

Yep

>         lwz 11,0(1)             //GPR3 pointing to 0?

Load r11 from address r1

>         lwz 0,4(11)		//GPR0 pointing to 4?

Load r0 from address r11+4

>         mtlr 0			//again this mt* function what does it?

Move To Link Register, i.e. restore the return address

>         lwz 31,-4(11)           //...

Load r31 from address r11-4

>         mr 1,11			//..

Move r11 to r1

>         blr			//...

Branch to Link Register, i.e. return from subroutine.

> TIA

You're welcome ;-)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



Reply to: