Question: Complete the ARM assembly language program below so that it implements the following C++ statements. Make a subroutine func2 that expects the input parameters to

Complete the ARM assembly language program below so that it implements the following C++ statements. Make a subroutine func2 that expects the input parameters to be in registers r2, r3, and r4 and returns the result in register r2. There is no need to use the stack.

------------------------------------------------------------------------

C++ Code

int func2(int);

int main(void)

{

const int size = 10;

int x[size] = (100, 3, -1, 2, 4, 4, 2, -1, 3, 100)

int y[size] = (10, 8, 6, 4, 2, 20, 18, 16, 14, 12)

int z[size] = (50, 45, 40, 35, 30, 25, 20, 15, 10, 5)

int w(size);

int i;

for (i = 0; i < size; i++)

{

w(i) = func2(x[i], y[i], z[i]);

}

)

int func2(int val0, val1, val2)

{

int i, result;

result = 0;

for (i = 0; i < val1; i++)

result = result + val2;

result = result + val0;

return result;

}

--------------------------------------------------------------------

AREA FUNCTION_CALL, CODE, READ

ENTRY

ADR r10, x

ADR r11, y

ADR r12, z

ADR r13, w

LDR r8, size

LDR r9, i

loopm CMP r9, r8

BGE done

INSERT CODE HERE

ADD r9, r9, #1

B loopm

INSERT CODE HERE

done B done

x DCD 100, 3, -1, 2, 4, 4, 2, -1, 3, 100

y DCD 10, 8, 6, 4, 2, 20, 18, 16, 14, 121

z DCD 50, 45, 40, 35, 30, 25, 20, 15, 10, 5

w SPACE 40

i DCD 0

size DCD 10

END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!