Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions