Subject: Re: PPC assembly
To: Dan Winship <danw@helixcode.com>
From: Bill Studenmund <wrstuden@zembu.com>
List: port-macppc
Date: 05/08/2000 09:45:29
On Fri, 5 May 2000, Dan Winship wrote:

> > r0 is hardwired to always contain 0 on some processors; I don't know  
> > if the ppc is one of them.
> 
> It's tricky. I believe the rule is that if you use it as the first
> operand, it always appears to contains 0, but if you use it as the
> second operand, it behaves normally. It may actually be the other way
> around though.

You got it right, Dan.

The idea here is that most all the operations are wired to be binary
operations - there's an rA and an rB. If you only need one register,
you're hosed. So the designers shorted r0 a little. If "0" appears in the
rA area, you get "0" instead of r0. "0" in the rB area of the instruction
gives you r0. Thus you can easily do binary and unary register
uses. :-) The only thing you can't do is r0, r0.

Take care,

Bill