In: Computer Science
int main()
{
float A[4] = { 0.51, 1.23, 7.4, 10.88};
float B[4] = { -11.1, 78.044, 12.009, -9.99};
float s = 0.0;
for (int i=0; i<4; i++)
{
s = s + A[i]*B[i];
}
}
change this c languange to arm assembly languange extension of vfp registor
here is the ARM gcc compliation
LC0:
.word 1057132380
.word 1067282596
.word 1089260749
.word 1093538939
.LC1:
.word 3241253274
.word 1117525639
.word 1094722781
.word 3240089354
main:
push {fp, lr}
add fp, sp, #4
sub sp, sp, #40
ldr r3, .L5
sub ip, fp, #28
ldm r3, {r0, r1, r2, r3}
stm ip, {r0, r1, r2, r3}
ldr r3, .L5+4
sub ip, fp, #44
ldm r3, {r0, r1, r2, r3}
stm ip, {r0, r1, r2, r3}
mov r3, #0
str r3, [fp, #-8] @ float
mov r3, #0
str r3, [fp, #-12]
b .L2
.L3:
ldr r3, [fp, #-12]
lsl r3, r3, #2
sub r2, fp, #4
add r3, r2, r3
ldr r2, [r3, #-24] @ float
ldr r3, [fp, #-12]
lsl r3, r3, #2
sub r1, fp, #4
add r3, r1, r3
ldr r3, [r3, #-40] @ float
mov r1, r3
mov r0, r2
bl __aeabi_fmul
mov r3, r0
mov r1, r3
ldr r0, [fp, #-8] @ float
bl __aeabi_fadd
mov r3, r0
str r3, [fp, #-8] @ float
ldr r3, [fp, #-12]
add r3, r3, #1
str r3, [fp, #-12]
.L2:
ldr r3, [fp, #-12]
cmp r3, #3
ble .L3
mov r3, #0
mov r0, r3
sub sp, fp, #4
pop {fp, pc}
.L5:
.word .LC0
.word .LC1