© Stephen Smith 2019
S. SmithRaspberry Pi Assembly Language Programminghttps://doi.org/10.1007/978-1-4842-5287-1_13

13. Conditional Instructions and Optimizing Code

Stephen Smith1 
(1)
Gibsons, BC, Canada
 

In Chapter 4, “Controlling Program Flow,” we learned how to branch code conditionally based on flags in the CPSR. In this chapter, we will look at how this can be generalized to all instructions.

In Chapter 1, “Getting Started,” we looked at the ARM Instruction Format and noted that nearly every instruction contains a 4-bit condition code. So far, we’ve ignored the purpose of these bits; now we’ll look at how to use them and why we want to execute instructions conditionally to reduce the number of branch instructions. We want to minimize the number ...

Get Raspberry Pi Assembly Language Programming: ARM Processor Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.