PowerPC Assembly/Printable version
| This is the print version of PowerPC Assembly
You won't see this message or any elements not part of the book's content when you print or preview this page.
Why Learn Assembly?[edit | edit source]
Assembly is the most primitive tool in the programmers toolbox. Entire software projects can be written without ever once looking at a single line of assembly code. So the question arises: why learn assembly? Assembly language is the closest form of communication that humans can engage in with a computer. Using assembly, the programmer can precisely track the flow of data and execution in a program. Also, another benefit to learning assembly, is that once a program has been compiled, it is difficult -- if not impossible -- to decompile the code. That means that if you want to examine a program that is already compiled, you will need to examine it in assembly language. Debuggers also will frequently only show the program code in assembly language. If nothing else, it can be beneficial to learn to read assembly language, if not write it.
Assembly language is also the preferred tool, if not the only tool available for implementing some low-level tasks, such as bootloaders, and low-level kernel components. Code written in assembly has less overhead than code written in high-level languages, so assembly code frequently will run much faster than programs written in other languages. Code that is written in a high-level language can be compiled into assembly, and "hand optimized" to squeeze every last bit of speed out of a section of code. As hardware manufacturers such as Intel and AMD add new features and new instructions to their processors, often times the only way to access those features is to use assembly routines. That is, at least until the major compiler vendors add support for those features.
Developing a program in assembly can be a very time consuming process, however. While it might not be a good idea to write new projects in assembly language, it is certainly valuable to know a little bit about assembly language anyway.
Who is This Book For?[edit | edit source]
This book is for those who are learning assembly for the first time, or hoping to optimize their PPC specific code, or even those hoping to learn more about a RISC processor.
Instruction Forms[edit | edit source]
All PowerPC instructions are four bytes long. Whenever the processor calculates the destination address of a branch, the two low-order bits are ignored, so the actual two low-order bits are always 0 in the destination address (i.e., every instruction is word-aligned).
Bits 0-5 of an instruction are specified by the op code, and also indicate the form of the instruction (how to divide up the remaining bits of the instruction into fields, and the meaning of each field).
Further reading[edit | edit source]
- "Assembler Language Reference for for POWER-based architectures". (includes both Power2 and PowerPC instruction sets).