A computer has three eight?element vectors in memory, Va, Vb, and Vc. Each element of a vector is a 32?bit word. Write the code to calculate all elements of Vc if the ith element is given by

Vci = ½ (Vai + Vbi)


The following provides suitable code and the output of the simulator when running this with test data.



ADR r0,Va ;r0 pointer to array Va

ADR r1,Vb ;r1 pointer to array Vb

ADR r2,Vc ;r2 pointer to array Vc

MOV r3,#8 ;r3 contains the size of the array (assume 8 here)

Loop LDR r5,[r0],#4 ;Repeat Get Va_i

LDR r6,[r1],#4 ; Get Vb_i

ADD r5,r5,r6 ;

MOV r5,r5,LSR #1 ; Calculate ½(Va_i + Vb_i)

STR r5,[r2],#4! ; save result

SUBs r3,r3,#1 ;

BNE Loop ;Until all done



Computer Science & Information Technology

You might also like to view...

Python recently surpassed the programming language ________ as the most popular data-science programming language.

a. DSPL b. Java c. C++ d. R

Computer Science & Information Technology

In the bubble sort algorithm, which code accomplishes swapping values in elements at positions index and index + 1?

A. list[index] = list[index + 1] list[index + 1] = list[index] B. list[index + 1] = list[index] list[index] = list[index + 1] C. list[index] = temp; list[index] = list[index + 1]; temp = list[index + 1]; D. temp = list[index]; list[index] = list[index + 1]; list[index + 1] = temp;

Computer Science & Information Technology

When working with arrays, you can use ____________________ in several ways: To hold the size of an array, as the array values, and as a subscript .

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which of the following is not a category that appears on the Assets panel?

A. Colors B. Graphics C. SWF D. Library

Computer Science & Information Technology