[英]ARM, help LDR instruction
I am studying for an ARM test and I have this code 我正在研究ARM测试,并且我有这段代码
AREA datos, DATA, READWRITE
long EQU 7*4
serie DCD 1, 2, 4, 6, 8, 7, 9
resul DCB 0
AREA prog, CODE, READONLY
ENTRY
mov r0, #0
eor r1, r1, r1 ;result variable
ldr r2, =serie **This one**
buc ldr r3, [r2, r0]
add r1, r1, r3
add r0, r0, #4
cmp r0, #long
bne buc
ldr r2, =resul **This one**
str r1, [r2]
fin b fin
END
And I'm debugging it with Keil, my problem is that I don't understand very well the instructionts marked. 我正在用Keil调试它,我的问题是我对标记的指令不太了解。
8: mov r0, #0
0x40000000 E3A00000 MOV R0,#0x00000000
9: eor r1, r1, r1 ;result variable
10:
0x40000004 E0211001 EOR R1,R1,R1
11: ldr r2, =serie
0x40000008 E59F201C LDR R2,[PC,#0x001C]
12: buc ldr r3, [r2, r0]
0x4000000C E7923000 LDR R3,[R2,R0]
13: add r1, r1, r3
0x40000010 E0811003 ADD R1,R1,R3
14: add r0, r0, #4
0x40000014 E2800004 ADD R0,R0,#0x00000004
15: cmp r0, #long
0x40000018 E350001C CMP R0,#0x0000001C
16: bne buc
17:
0x4000001C 1AFFFFFA BNE 0x4000000C
18: ldr r2, =resul
0x40000020 E59F2008 LDR R2,[PC,#0x0008]
19: str r1, [r2]
20:
0x40000024 E5821000 STR R1,[R2]
21: fin b fin
I have this if I dissasembly it with Keil, then I know that LDR R2, =serie
its the same that LDR R2,[PC, #offset]
but the value of #offset are placed in the Literal Pool? 如果我对Keil感到厌烦,那么我就知道了这一点,那么我知道
LDR R2, =serie
是否与LDR R2,[PC, #offset]
相同,但LDR R2,[PC, #offset]
的值放在文字池中? I don't know why the value is 0x001C
. 我不知道为什么值是
0x001C
。
PD: Sorry for my english, I know its not very good. PD:对不起,我的英语,我知道那不是很好。
Here is an object dump of your program (modified to run on Raspberry Pi). 这是程序的对象转储(已修改为在Raspberry Pi上运行)。
Disassembly of section .text:
00000000 <main>:
0: e3a00000 mov r0, #0
4: e0211001 eor r1, r1, r1
8: e59f201c ldr r2, [pc, #28] ; 2c <buc+0x20>
0000000c <buc>:
c: e7923000 ldr r3, [r2, r0]
10: e0811003 add r1, r1, r3
14: e2800004 add r0, r0, #4
18: e350001c cmp r0, #28
1c: 1afffffa bne c <buc>
20: e59f2008 ldr r2, [pc, #8] ; 30 <buc+0x24>
24: e5821000 str r1, [r2]
28: e12fff1e bx lr
2c: 00000000 andeq r0, r0, r0
30: 0000001c andeq r0, r0, ip, lsl r0
Disassembly of section .data:
00000000 <serie>:
0: 00000001 andeq r0, r0, r1
4: 00000002 andeq r0, r0, r2
8: 00000004 andeq r0, r0, r4
c: 00000006 andeq r0, r0, r6
10: 00000008 andeq r0, r0, r8
14: 00000007 andeq r0, r0, r7
18: 00000009 andeq r0, r0, r9
0000001c <resul>:
1c: 00000000 andeq r0, r0, r0
Disassembly of section .ARM.attributes:
00000000 <.ARM.attributes>:
0: 00001541 andeq r1, r0, r1, asr #10
4: 61656100 cmnvs r5, r0, lsl #2
8: 01006962 tsteq r0, r2, ror #18
c: 0000000b andeq r0, r0, fp
10: 01080206 tsteq r8, r6, lsl #4
14: Address 0x00000014 is out of bounds.
There is a .text section for the program and .data section for the data (DCD, DCB). 程序有一个.text节,数据(DCD,DCB)有一个.data节。 At the end of the program, there are two words that will contain the address of the .data section that are defined "serie" and "resul".
在程序的最后,有两个单词将包含.data节的地址,它们被定义为“ serie”和“ resul”。 The address of those address in
ldr r2, [pc, #28]
is the value of the pc reg + dec 28 = hex 2c. 这些地址在
ldr r2, [pc, #28]
中的地址ldr r2, [pc, #28]
是pc reg + dec 28 = hex 2c的值。 The same is true with the ldr r2, [pc, #8]
, value in the pc reg + dec 8 = hex 30. 对于
ldr r2, [pc, #8]
,pc reg + dec 8 =十六进制30中的值也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.