Microsoft Word - iOSAppReverseEngineering.docx

(Romina) #1

Figure 6-3 Execute instructions out of order


The instructions’ execution has been disordered to 1, 5, 4, 2, 3 and 6, which is bizarre and


remarkable. This kind of “disorder” is officially called “branch” or “jump”, which makes loop


and subroutine possible. For example:


// endless()
endless:
operate op1, op2
branch endless
return // Dead loop, we cannot reach here!
In actual cases, conditional branches, which are triggered under some specific conditions,

are the most practical branches. “if else” and “while” are both based on conditional branches. In


ARM assembly, there are 4 kinds of conditional branches:


² The result of operation is zero (or non-zero).


² The result of operation is negative.


² The result of operation has carry.


² The operation overflows (for example, the sum of two positive numbers exceeds 32 bits).^


These operation results are often represented as flags and are saved in the Program Status


Register (PSR). Some instructions will change these flags according to their operation results,


and conditional branches decide whether to branch according to these flags. The pseudo code


below shows an example of for loop:

Free download pdf