ARM Assembler Instruction Cheatsheet

Post Reply
Go4IT
Pro
Posts: 967
Joined: 08 Feb 2019, 12:25

ARM Assembler Instruction Cheatsheet

Post by Go4IT »

Here i'd like to post some common Assembler commands found in disassembly of several firmwares utilizing ARM CPUs (like MAC7116 of IPC).
The headings of the replies are set to the topic (e.g. "Storing data to memory locations"). In each topic post some samples and explain them.
Go4IT
Pro
Posts: 967
Joined: 08 Feb 2019, 12:25

Storing data to memory locations

Post by Go4IT »

Code: Select all

STRB R1, [R0,#1]
This command stores one Byte, the lowest byte (Bits 7-0) of the current value of R1 (remember: every ARM register is 32-Bit wide) to the memory location indicated by "[R0,#1]", so register R0 contains a fixed value (base address) and "#1" gives the offset to that value, so it's stored at "R0+1".
Go4IT
Pro
Posts: 967
Joined: 08 Feb 2019, 12:25

Retrieving data from memory locations

Post by Go4IT »

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Retrieve a 4 Byte value (32 Bit)

Code: Select all

LDR    R0, =0xFC000000
By reading this instruction it's clear what it does, loading register R0 with the value 0xFC000000. What's interesting here is the "=" which denotes that the value is not located next to the LDR opcode itself, but within a range in WORD-boundaries (a WORD is 4 Bytes in ARM-Architecture). In Thumb-Mode, this instruction is only two bytes long, giving the distance to the value itself in WORD counts.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Retrieve a single Byte:

Code: Select all

LDRB    R1, [R0,#2]
Loads a Byte from memory location "R0+2" (R0 containing the base memory address and the index number 2 given as immediate value) and store it in the lowest Byte of the 32-Bit register R1.
Post Reply