PowerPC Tutorial

Previous Chapter

Chapter 5: Basic Registers

Other than memory, there's one more place a CPU will keep data at. This place is known as the Registers. The Registers are important because the data here is what is used for the calculation of many Instructions.

In a typical PowerPC CPU, there are 100's of Registers. However, most of these we don't need to worry about for now. Registers can be categorized into 3 groups..

We will focus on the General Purpose Registers. There are 32 GPRs. Register 0 thru Register 31, or also known as r0 thru r31. Each GPR is 32-bits in length. Therefore a word value is the maximum size data type that can fit into a GPR.

Sometimes a GPR will contain a Memory Address (to use as a reference for a task), or it can contain a basic integer value (to represent something such as item count). Only whole numbers are able to exist within a GPR. Partial numbers have to be in Floating Point form, and are used in the FPRs.

Two of the GPRs have alternate names. r1 is known as the Stack Pointer (sp). Basically, this register is used to allocate memory to store data to. It will always contain a Memory Address. We will cover this more in Chapter 24 once you've become more advanced. r2 is known as the Register Table of Contents (rtoc). There is also a third GPR that is sometimes mentioned by an alias. r13 may be referred to as "got" which stands for Global Offset Table. r2 and r13 are usually memory addresses that will be used as a reference point for access to important data.

We do need to broadly cover some SPR's by the way. LR is the Link Register. It is used to navigate to/from Functions. You will learn more about Functions in Chapter 23. This register will always contain a Memory Address. CTR is the Count Register. It is used for making Loops, more on this in Chapter 13. PC is the Program Counter. It always contains the Memory Address of the next Instruction that is to be executed.


Next Chapter

Tutorial Index