Status register

The CPSR(status register) is used to store data. The CPSR works in bits, with each bit having a different meaning and recording specific information

N(Negative)

  • The 31st bit is the N bit, the sign flag bit,
  • It records whether the result of the relevant instruction is negative after it is executed. If it is negative, N = 1; if it is non-negative, N = 0

Z(Zero)

  • The 30th bit is Z, the 0 bit, which means that the result is 0, Z = 1, and if the result is not 0, then Z = 0

C (Carry)

  • Bit 29 is C, which carries the flag bit for unsigned operations
  • Addition: C = 1 if the result of the operation produces a carry (unsigned overflow), otherwise C = 0;
  • Subtraction operations (including CMP) : C = 0 when a debit occurs (unsigned overflow), otherwise C = 1

V(Overflow)

  • The 28th bit is V, the overflow flag bit. If it exceeds the range it can represent in symbolic operation, it is called overflow
  • Positive + positive = negative overflow
  • Negative + negative = positive overflow
  • Positive and negative numbers cannot overflow

Whether it’s a signed number or an unsigned number, as long as he calculates the result he will interpret the result as the corresponding sign number in the corresponding position

adrp & add

First find the constant area of the page, find the approximate location and then add the offset value, to get the final address

VAT code

Executable files are disassembled using hopper softwareThe function can be searched on the left, and the execution process of the function on the right, etc

Also the function

Let’s do another function with if else

cycle

do while

while

The for loop

You can see that the for loop has the same logic as the while loop

switch case

When the case value exceeds 3

Pointer disassembly

Pointers are in assembly

The pointer’s width is 8

Compiler optimization

OC code disassemble

object

Block

GlobalBlock analysis

StackBlock analysis