Chapter 7 - PowerPC Registers overview.

- GPRs - General-Purpose Registers
  FPRs - Floating-Point Registers

  There are 64 of them: 32 integer registers (GPR0 to GPR31) and 32  floating-
  point registers (FPR0 to FPR31). It's common usage to name them  r0  to  r31
  (integers) and f0 to f31 (floats).

  MorphOS uses the standard System V.4 ABI. This  defines  how  registers  are
  used.
  A complete description of the ABI is available in the MorphOS SDK:
  SDK:Documentation/Articles/Porting/PowerOpenAPI.txt file.

  In short:
  The first integer argument of a function is in r3, the second is in r4,  the
  third is in r5...
  The first floating-point argument is in f1, the second is in f2, etc...
  The function return value is in r3 if it's an integer and in f1  if  it's  a
  float.

  r2 contains MorphOS' EmulHandle pointer and must always be preserved.
  All emulated 68k registers (d0 to d7 and a0 to a7) are available through it.
  They can also be directly mapped on PowerPC registers (r16 to r31).

  For more information about MorphOS specific points, please take  a  look  at
  SDK:Documentation/Articles/Porting/MorphOS.txt file.


- DAR - Data Address Register
  Contains the invalid address which was accessed and caused the exception.


- SRR0 - Machine Status Save/Restore Register 0
  On an exception, it contains the address of the instruction which caused it.
  This is the most important register when debugging.


- LR - Link Register
  When calling a sub-routine, LR  contains  the  address  of  the  instruction
  following the calling one. So LR points to the  instruction  executed  after
  the program returns from the current sub-function.
  With this register, it's possible to track all functions executed before the
  current one.


- CTR - Count Register
  Often used to implement loops. In that case, it contains the loop count.


For more complete information about PowerPC internal, please take  a  look  at
Freescale manual: http://www.freescale.com/files/32bit/doc/user_guide/MPCFPE_AD_R1.pdf.

<< A commented debug log example | FAQ >>