Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

Are we running out of nonrenewable resources?

Answered: 1 week ago