Question

In: Computer Science

int main() { float A[4] = { 0.51, 1.23, 7.4, 10.88}; float B[4] = { -11.1,...

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

Solutions

Expert Solution

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


Related Solutions

#include <stdio.h> int main(void) { float funds = 1.0, cost = 0.1; int candies = 0;...
#include <stdio.h> int main(void) { float funds = 1.0, cost = 0.1; int candies = 0; while(cost <= funds) { candies += 1; funds -= cost; cost += 0.1; } printf("%d candies with $%.2f left over.\n",candies,funds); return 0; } When you compile and run this code you get 3 candies with $0.40 left over. Without knowing how floating point numbers work in a computer, would this result be expected? Explain why or why not. Explain why this result, in fact,...
I need a Flowgorithm chart of this #include using namespace std; int main() {    float...
I need a Flowgorithm chart of this #include using namespace std; int main() {    float CISBook[] = {55.5,35.8,67.5};    float MATHBook[] = {25.5, 54.5};    float MECBook[] = {65.0,75.5,86.8};    float sumCIS=0, sumMATH = 0, sumMEC = 0;              for (int i=0; i<4; i++)    {sumCIS += CISBook[i];}       for (int i=0; i<3; i++)    {sumMATH += MATHBook[i];}       for (int i=0; i<4; i++)    {sumMEC += MECBook[i];}       cout<<"\nTotal for CIS Books:...
REQUIREMENTS: Write a function that matches the following declaration: int InRectangle( float pt[2], float rect[4] );...
REQUIREMENTS: Write a function that matches the following declaration: int InRectangle( float pt[2], float rect[4] ); Argument pt[2] defines a point on the plane: pt[0] is the x-coordinate, pt[1] is the y-coordinate. Argument rect[4] defines a rectangle on the same plane. rect[0] and rect[1] define the x- and y- cordinates respectively of one corner of the rectangle. rect[2] and rect[3] define the opposite corner. Coordinates may be any valid floating point value, including negative values. The function returns int 0...
Given int B[4][4]={...}; Write a code segment that exchange the values about the main diagonal of...
Given int B[4][4]={...}; Write a code segment that exchange the values about the main diagonal of the matrix.
Analyze following program and Find Syntax errors. #include<iostream> int show(int x) int main() {     int A,B;...
Analyze following program and Find Syntax errors. #include<iostream> int show(int x) int main() {     int A,B;       char B=10; cout<<”Enter Value of A”; cin<<A; show(A) show(50)          }       cin.get(); } int show(int x); { cout<<”Value is =” <<X cout<<endl; }
9. #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile; inFile.open("bmi.txt");...
9. #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile; inFile.open("bmi.txt"); while (!inFile.eof()) { inFile >> bmi; if( bmi < 18.5) { cout << bmi << " is underweight " ; } else if( bmi >= 18.5 && bmi <= 24.9) { cout << bmi << " is in normal range " ; } else if( bmi >= 25.0 && bmi <= 29.9) { cout << bmi << " is overweight " ; } else...
#include <stdio.h> int main() { float sum_salary=0,sum_raise=0,sum_newsalary=0; while(1) { float salary,rate,raise,newsalary; printf("Enter Salary :"); scanf("%f",&salary); if(salary==-1)...
#include <stdio.h> int main() { float sum_salary=0,sum_raise=0,sum_newsalary=0; while(1) { float salary,rate,raise,newsalary; printf("Enter Salary :"); scanf("%f",&salary); if(salary==-1) { if(sum_salary==0) return 0; else { printf("Total Salary :%f Total raise :%f Total New Salary: %f",sum_salary,sum_raise,sum_newsalary); return 0; } } else { if(salary>=0 &&salary<30000) rate=7; else if(salary>=30000 &&salary<=40000) rate=5.5; else if(salary>40000) rate=4; raise=rate*salary/100; newsalary=salary+raise;    sum_salary=salary+sum_salary; sum_raise=raise+sum_raise; sum_newsalary=newsalary+sum_newsalary; printf("Salary :%f rate :%f Raise :%f New Salary: %f\n",salary,rate,raise,newsalary); } } } Hi can you please make sure that the following program will ask the user...
package dealership; public abstract class Vehicle { private float dealerPrice; private int year; public Vehicle(float d,...
package dealership; public abstract class Vehicle { private float dealerPrice; private int year; public Vehicle(float d, int y) { dealerPrice = d; year = y; } public float getDealerPrice() { return dealerPrice; } public int getYear() { return year; } public abstract float getStickerPrice(); } In the space below write a concrete class Car in the dealership package that is a subclass of Vehicle class given above. You will make two constructors, both of which must call the superclass constructor....
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x = 3;     i = fun(x);     printf("%d\n", i);     return 0; } int fun(int i) {      int res = 0;      res = pow (i , 3.0);      return ( res); }
int a = 3; int b = -2; if((a>0)&&(b>0)){ if (a>b) { System.out.println("A"); } else {...
int a = 3; int b = -2; if((a>0)&&(b>0)){ if (a>b) { System.out.println("A"); } else { System.out.println("B"); } } else if ((b<0)||(a<0)) { System.out.println("C"); } else { System.out.println("D"); }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT