Addressing Memory
Addressing Memory
&
Architecture
Addressing Memory
2 ARM Memory Map
The segments of a program in execution
The Memory Map
3
For example
CMP R0, #22
ADD R1, R2, #18
MOV R1, #30
MOV R1, #0xFF
Register Indirect Addressing
13
.data
b: .word 20
c: .word 30
Why does the ARM PC register point to the instruction after the next one to be executed? - Stack Overflow
Integer (word) Array Data
● Similar data can be grouped
together into an array.
● An array stores its contents at
sequential data addresses in
memory.
● Each array element is identified
by a number called its index.
● The number of elements in the
array is called the length of the
array.
Iterating over an array of words
.global _start
_start:
ldr r0, =array1 // array base pointer
mov r1, #0 // offset
mov r2, #0 // loop counter
loop:
cmp r2, #6
bge end
ldr r3, [r0, r1] // read base + offset to reg
add r3, r3, #10 // add 10 to the value
str r3, [r0, r1] // write reg to base + offset
add r2, r2, #1 // inc loop
lsl r1, r2, #2 // calc offset
b loop
end:
svc #0
.data
We can execute
Also:
Please note
Operations within an instruction. Consider the code
mov r4, #1
lsl r4, r4, #1
ldr r5, [r0, r4, lsl #1]
● Java:
○ String message= "Hello";
● ARM:
.data
message: .asciz "Hello World!"
Iterating over an array of "chars"
26
Part way
through
execution
get next character from the string
31
.data
message: .asciz "Hello World!0"