PowerPC Assembly/Introduction

From Wikibooks, open books for an open world
Jump to navigation Jump to search

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.