Arm Mnemonics
Below is a detailed list of the ARM 32-bit architecture (also known as ARMv7) instructions, with explanations, examples, and usage for each instruction type.
Data Processing Instructions:
ADD (Addition)
Description: Adds two operands and stores the result in the destination register.
Example:
ADD R0, R1, R2Adds the values in registers
R1andR2, and stores the result inR0.
SUB (Subtraction)
Description: Subtracts the second operand from the first operand and stores the result in the destination register.
Example:
SUB R0, R1, R2Subtracts the value in
R2fromR1and stores the result inR0.
RSB (Reverse Subtraction)
Description: Performs subtraction in reverse order.
Example:
RSB R0, R1, R2Subtracts the value in
R1fromR2and stores the result inR0.
MUL (Multiply)
Description: Multiplies two operands and stores the result in the destination register.
Example:
MUL R0, R1, R2Multiplies the values in
R1andR2, and stores the result inR0.
SDIV (Signed Division)
Description: Divides the first operand by the second operand (signed) and stores the result in the destination register.
Example:
SDIV R0, R1, R2Divides the value in
R1by the value inR2(signed division) and stores the result inR0.
UDIV (Unsigned Division)
Description: Divides the first operand by the second operand (unsigned) and stores the result in the destination register.
Example:
UDIV R0, R1, R2Divides the value in
R1by the value inR2(unsigned division) and stores the result inR0.
AND (Bitwise AND)
Description: Performs a bitwise AND operation between two operands and stores the result in the destination register.
Example:
AND R0, R1, R2Performs a bitwise AND between the values in
R1andR2, and stores the result inR0.
ORR (Bitwise OR)
Description: Performs a bitwise OR operation between two operands and stores the result in the destination register.
Example:
ORR R0, R1, R2Performs a bitwise OR between the values in
R1andR2, and stores the result inR0.
EOR (Bitwise XOR)
Description: Performs a bitwise XOR operation between two operands and stores the result in the destination register.
Example:
EOR R0, R1, R2Performs a bitwise XOR between the values in
R1andR2, and stores the result inR0.
BIC (Bitwise Clear)
Description: Performs a bitwise AND between the first operand and the negation of the second operand and stores the result in the destination register.
Example:
BIC R0, R1, R2Performs a bitwise AND between
R1and the negation ofR2, and stores the result inR0.
TST (Test)
Description: Performs a bitwise AND between two operands, but does not store the result; only updates the condition flags.
Example:
TST R1, R2Performs a bitwise AND between
R1andR2, updating the flags based on the result.
CMP (Compare)
Description: Subtracts the second operand from the first operand, but does not store the result; only updates the condition flags.
Example:
CMP R1, R2Subtracts
R2fromR1and updates the flags based on the result.
Load and Store Instructions:
LDR (Load Register)
Description: Loads data from memory into a register.
Example:
LDR R0, [R1, #4]Loads the value from memory at address
R1 + 4into registerR0.
STR (Store Register)
Description: Stores data from a register into memory.
Example:
STR R0, [R1, #4]Stores the value in
R0into memory at addressR1 + 4.
LDM (Load Multiple)
Description: Loads multiple registers from memory.
Example:
LDM R0, {R1, R2, R3}Loads the values from memory into registers
R1,R2, andR3starting at addressR0.
STM (Store Multiple)
Description: Stores multiple registers to memory.
Example:
STM R0, {R1, R2, R3}Stores the values from registers
R1,R2, andR3into memory starting at addressR0.
LDRB (Load Byte)
Description: Loads a byte from memory into a register.
Example:
LDRB R0, [R1]Loads a byte from memory at address
R1into registerR0.
STRB (Store Byte)
Description: Stores a byte from a register into memory.
Example:
STRB R0, [R1]Stores a byte from register
R0into memory at addressR1.
Branch Instructions:
B (Branch)
Description: Performs an unconditional jump to a specified label.
Example:
B labelJumps to the instruction at the specified label.
BL (Branch with Link)
Description: Performs a branch and stores the return address in the link register (
LR).Example:
BL functionBranches to
functionand saves the return address inLR.
BX (Branch and Exchange)
Description: Branches to an address stored in a register and optionally switches the processor mode (ARM/Thumb).
Example:
BX R0Branches to the address stored in
R0and switches to the appropriate execution state (ARM or Thumb).
BLX (Branch with Link and Exchange)
Description: Performs a branch with link and switches between ARM/Thumb states.
Example:
BLX R0Branches to the address in
R0, saves the return address inLR, and switches to the appropriate execution state.
Shift and Rotate Instructions:
LSL (Logical Shift Left)
Description: Shifts the bits of a register to the left by a specified number of positions, filling with zeros.
Example:
LSL R0, R1, #2Shifts the bits of
R1left by 2 positions, stores the result inR0.
LSR (Logical Shift Right)
Description: Shifts the bits of a register to the right by a specified number of positions, filling with zeros.
Example:
LSR R0, R1, #2Shifts the bits of
R1right by 2 positions, stores the result inR0.
ASR (Arithmetic Shift Right)
Description: Shifts the bits of a register to the right by a specified number of positions, preserving the sign bit (used for signed numbers).
Example:
ASR R0, R1, #2Shifts the bits of
R1right by 2 positions, preserving the sign bit, and stores the result inR0.
ROR (Rotate Right)
Description: Rotates the bits of a register to the right by a specified number of positions.
Example:
ROR R0, R1, #2Rotates the bits of
R1right by 2 positions, storing the result inR0.
Miscellaneous Instructions:
NOP (No Operation)
Description: Does nothing and is typically used for timing or padding purposes.
Example:
NOPDoes nothing.
SWI (Software Interrupt)
Description: Triggers a software interrupt, typically used for making system calls.
Example:
SWI 0Issues a software interrupt with code 0.
CMP (Compare)
Description: Subtracts two operands and updates the condition flags without storing the result.
Example:
CMP R0, R1Subtracts
R1fromR0and updates the flags based on the result.
TST (Test)
Description: Performs a bitwise AND between two operands and updates the condition flags.
Example:
TST R0, R1Performs a bitwise AND between
R0andR1and updates the flags.
System Instructions:
MRS (Move from System Register)
Description: Moves the value from a system register into a general-purpose register.
Example:
MRS R0, CPSRMoves the value of the
CPSR(Current Program Status Register) intoR0.
MSR (Move to System Register)
Description: Moves a value from a general-purpose register into a system register.
Example:
MSR CPSR, R0Moves the value in
R0into theCPSR.
This list outlines the key instructions for ARM 32-bit (ARMv7) assembly language, including arithmetic, logic, memory operations, control flow, and system-level instructions. These are fundamental for developing software on ARM-based systems such as mobile devices, embedded systems, and older ARM architectures.