I'm a really beginner with ARM. I write a very simple program to find the sum of three values Q,R,S and store it in the memory. However it doesn't works. Someone can show me what is my mistake. Thanks for your help.
AREA Example3, CODE, READONLY
EXPORT SystemInit
EXPORT __main
ENTRY
SystemInit
__main
LDR R1,Q ;load r1 with Q
LDR r2,R ;load r2 with R
LDR r3,S ;load r3 with S
ADD r0,r1,r2;add Q to R
ADD r0,r3;add in S
LDR r4,=Q
STR r0,[R4] ;store result in Q
;Stop B Stop
P SPACE 4 ;save one word of storage
Q DCD 2 ;create variable Q with initial value 2
R DCD 4
S DCD 5
END
To add into mwsealey's answer:
in Cortex A Series Programmer's Guide:
A1.46 LDR (pseudo instruction)
syntax
LDR{cond}{.w} Rt, =expr
LDR{cond}{.w} Rt, label_expr
expr is a numeric value
label_expr is a label, optionally plus or minus a numeric value
Watch out not to get confused with these two.
[EDIT]
Example:
.section .vector
.align 4
ldr pc, =_start
ldr pc, =0 @ swi
ldr pc, =0 @ prefetch_abort
ldr pc, =0 @ data_abort
ldr pc, =0 @ not_used
ldr pc, =0 @ irq
ldr pc, =0 @ fiq
.text
_start:
...
00000000 <.vector>:
0: e59ff014 ldr pc, [pc, #20] ; 1c <gdb_check_breakpoint-0x8>
4: e3a0f000 mov pc, #0
8: e3a0f000 mov pc, #0
c: e3a0f000 mov pc, #0
10: e3a0f000 mov pc, #0
14: e3a0f000 mov pc, #0
18: e3a0f000 mov pc, #0
1c: 00001f04 andeq r1, r0, r4, lsl #30
00001f04 <_start>:
1f04: e59f408c ldr r4, [pc, #140] ; 1f98 <loop$+0x88>
1f08: e59f508c ldr r5, [pc, #140] ; 1f9c <loop$+0x8c>
1f0c: e3a0641f mov r6, #520093696 ; 0x1f000000
[/EDIT]