Summary of common ARM assembly instructions

 

jump instruction

  • B unconditional jump
  • BL unconditional jump with link
  • BX Unconditional jump with state transition
  • BLX unconditional jump with link and state

Memory and Register Interaction Data Instructions ( Core )

Storage: main memory and internal memory

The data placed in the register: it can be a string, a number, or an address, it can put various types of data

Storage address unit: the address (eg 0x00004000) and the value present in the address

  • LDR: Load data from memory to memory ← Load

LDR R8,[R9,#04] R8 is the register of the data to be loaded, and the load value is the storage unit pointed to by R9+0x4

  • STR: Store the data of the register in the memory →Store

STR R8,[R9,#04] Store the data of the R8 register to the storage unit pointed to by R9+0x4

  • LDM: Load data from memory to register list →

LDM R0,{R1-R3} load the data of the storage unit pointed to by R0 into the R1, R2, R3 registers in turn

  • STM: Store the data of a register list into the specified memory
  • PUSH: push a register value onto the stack
  • POP: push stack value to register
  • SWP: Swap data between registers and memory

SWP R1, R1 [R0] Swap the contents of the R1 register with the memory location pointed to by R0

Heap, queue: data structure, the stack is vertical, last in first out, and data can only be filled in from the top of the stack

data transfer instructions

  • MOV: Move immediate data or register data to destination register

MOV R0, #8 :R0=0x8

data arithmetic instruction

  • ADD:+
  • SUB:—
  • I HAVE:*
  • DIV:  /

Data logic operation instructions

  • AND: AND
  • or: ORR
  • EOR
  • LSL: Logical Left Shift ←
  • LSR: Logical shift right →
  • LSL R0,R1,#2:R0=R1*4

Shift: The essence is multiplication, division, similar to decimal point shift, but opposite. Moving the decimal point to the left makes the number smaller; moving the decimal point to the right makes the number larger.

But the logical shift, the left shift becomes larger, the right shift becomes smaller, and it is performed in multiples of 2, because it is binary.

compare instruction

  • CMP: Compare
  • CMP R0 #0: The value in the R0 register is compared to 0

Flag bit: such as the z bit, this can be seen in the register window during dynamic debugging

other instructions

  • Coprocessor Command: SWT (Switch User Mode)
  • Pseudo-instruction: DCB

register addressing mode

  • Immediate addressing: MOV R0, #1234→R0=0X1234
  • Register addressing: MOV R0, R1→R0=R1
  • Register shift addressing: MOV R0, R1, LSL #2→R0=R1*4
  • Register indirect addressing: LDR R0,[R1]→Use the value in the R1 register as the address, take out the value in the address and assign it to R0
  • Register indirect base address offset addressing: LDR R0, [R1, #-4] → use the value of the R1 register -0x4 as the address, and take the value in the address to R0

Assembly understanding of int a=0; this simple high-level language

First, a memory storage unit will be opened, and then the number 0x0 will be put into the R0 register, and then the data of the R0 register will be put into the memory storage unit. So: MOV R0, #0 STR R0, [R11, #0x14+var_20]

Note: The variable depends on the address of the storage unit. Don't think it is a register. It can be seen this way when it is simple, but imagine how many registers are needed if the register is a variable. A register is a bridge, something that interacts with memory, which is a storage unit address.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325854717&siteId=291194637