Assembly ARM汇编到C代码
我想弄清楚arm中的这个函数是做什么的Assembly ARM汇编到C代码,assembly,arm,Assembly,Arm,我想弄清楚arm中的这个函数是做什么的 00000000 <ibisFunction>: 0: e1510002 cmp r1, r2 4: e92d0030 push {r4, r5} 8: aa000009 bge 34 <ibisFunction+0x34> c: e080c102 add r12, r0, r2, lsl #2 10: e0803101 add r3, r0, r1, lsl #2 14: e59c4000 ldr r4,
00000000 <ibisFunction>:
0: e1510002 cmp r1, r2
4: e92d0030 push {r4, r5}
8: aa000009 bge 34 <ibisFunction+0x34>
c: e080c102 add r12, r0, r2, lsl #2
10: e0803101 add r3, r0, r1, lsl #2
14: e59c4000 ldr r4, [r12]
18: e5935000 ldr r5, [r3]
1c: e2811001 add r1, r1, #1
20: e2422001 sub r2, r2, #1
24: e1510002 cmp r1, r2
28: e40c5004 str r5, [r12], #-4
2c: e4834004 str r4, [r3], #4
30: bafffff7 blt 14 <ibisFunction+0x14>
34: e8bd0030 pop {r4, r5}
38: e12fff1e bx lr
我必须在C中找到等价物,我已经得到:
int* ibisFunction(int *a, int b, int c){
if (b<c){
d=a[c];
e=a[c];
while (b<c){
f=g;
g=e;
b++;
c--;
d[]=g;
e[]=f;
}
}
}
int*ibisFunction(int*a、int-b、int-c){
如果(b我认为这更像是:
uint32_t ibisFunction(uint32_t *a, int b, int c){
while (b < c) { // r1, r2
d = a[c]; // r4, using r12 as address
e = a[b]; // r5, using r3 as address
a[--c] = e; // STR r5 to r12 - 4
a[++b] = d; // STR r4 to r3 + 4
}
return a;
}
uint32\u t ibisFunction(uint32\u t*a、int b、int c){
而(b
你怎么知道你做错了什么?(我不是否认你做了,只是试图理解上下文。)你可能想看看以下几件事:(1)你的前两个作业有A[c]
作为RHS,但相应的汇编代码在这些地方有不同的东西;(2)有些赋值看起来像d[]=g
,但在方括号内没有任何内容,这是不正确的;(3)C代码没有反映地址28和2C的后索引寻址的效果。
uint32_t ibisFunction(uint32_t *a, int b, int c){
while (b < c) { // r1, r2
d = a[c]; // r4, using r12 as address
e = a[b]; // r5, using r3 as address
a[--c] = e; // STR r5 to r12 - 4
a[++b] = d; // STR r4 to r3 + 4
}
return a;
}