Question: Write common assembly language (RISC) programs to a) sum the first n elements of an array A, and b) compute r = ab for unsigned

Write common assembly language (RISC) programs to a) sum the first n elements of an array A, and b) compute r = ab for unsigned integers a and b. Each program will consist of a driver and a subprogram. The drivers will 1) read one or more values from the keyboard, 2) call the subprogram, and 3) print a result. The subprograms must not: ? store into memory, ? use registers $1 $9, or ? make system calls.The driver will read n from the keyboard and pass it to the subprogram in register $A. The array A will be at location 0x4400 in memory (@A = @A[0] = 0x4400). The driver will pass this address to the subprogram in register $B. The subprogram (starting at address 0xDD66) will expect the return address of the driver to be in register $E. It will return the sum in register $F. The driver will print this result. The driver will a and b. from the keyboard and pass them to the subprogram in registers $A and $B (respectively). The subprogram (starting at address 0xEE88), will expect the return address of the driver in register $E and return r = ab(algorithm on the next slide) in register $F. The driver will print this result.

Here is the algorithm to compute r = ab:

set r ? 1, m ? a, n ? b repeat until n == 0

if n is odd r ? rm

m ? mm

n ? n/2 return r

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 Databases Questions!