Thursday, 1 October 2015

ARM Assembly cheat sheet

ARM assembly

Instruction set


nop

No instruction. Does nothing. Used for alignment.


b

Branch off and go to a label.


Example:
b start
Execution goes to the label start.


mov

Move a value to a register. 8 bits maximum.


Example:
mov r0,#1
Moves value 1 to r0. r0 equals 1.


add

Adds two values together and place it to a register.


Example:
add r0,r1,r2
Adds r1 and r2 together. Then places it in r0.


ldr

Load a value to a register. Use this instruction when mov can't.


Example 1:
ldr r0,=r1
Loads r1's address to r0. Not r1's value.


Example 2:
ldr r0, [r1]
Loads value from given address(r1's value) and place it in r0.


Example 3:
ldr r0, [r1,r2]
Loads value from given address(r1's and r2's value) and place it in r0.


Example 4:
ldr r0,=0x10000000
Place 0x10000000 into r0. r0 equals 0x10000000.


str

Store value into memory location.Memory location is the data section.


Example:
str r0,[r1]
Store r0's value in the at the address given(r1's value).


cmp

Compares two registers and see if they are above zero. It subtracts internally.


Example 1:
cmp r0,r1
Sets N,Z,V,C condition flags with the data of r0-r1. Negative,Zero,Overflow,Carry.


Example 2:
cmp r0,#3
bge start
Performs r0-3.
If it is negative then N = true.
If it is overflowing then V = true.
If N == V or GE then go to start label.


bge

Checks if N == V or GE then goes to the branch see above.




Software used: ARMSim

No comments:

Post a Comment