Re: some basic problems with ppc assembler
Benjamin Herrenschmidt wrote:
The stwu will do r1=r1-32 and store old r1 there (stack pointer). This
will basically sets up the stackframe for the function. The LR is backed
up in r0 (the return address) and stored in the stackframe. r31 is a
non-volatile register, since the compiler thinks it will need it, it
backs it up
(though the reason it uses it is unclear, looks like lack of
optimisations). Finally, it bask up r1 (stack pointer) to r31, I'm not
sure why at this point.
The stwu r1,-32(r1) makes room on the stack, but r31 is the
frame pointer. Not that this function uses it, and of course
it can be optimized away to use only r1 (the stack pointer).