Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS-315 Program 4 USING MIPS ASSEMBLY This program will perform several tasks with arrays of floating-point values. All floating-point values will be double-precision, and all

CS-315 Program 4

USING MIPS ASSEMBLY

This program will perform several tasks with arrays of floating-point values. All floating-point values will be double-precision, and all arguments will be passed on the stack.

To finish this program, you will need a main associated with seven subprograms:

Main will first call create_array. Then create_array will call allocate_array todynamically allocate an array of double precision floating point numbers, and callread_array to read double-precision numbers into the array. After return to main, main must store the base address and array length in properly declared static variables. It should also print the array use print_array subprogram. Next, the main will prompt the user for a stride value N, and call print_every_nth using the created array and stride value N to print all values has their index divisible by N. Finally, Main will call theget_average to calculate the average value of the array. The get_average should call the get_sum in the process of calculating the average

create_array will have no argument IN and two arguments OUT:

$sp+0 - array base address (OUT)

$sp+4 - array length (OUT)

create_array will call subprogram allocate_array to allocate an array of double precision floating point numbers dynamically. Then it will call read_array to fill outthe array. Lastly, create_array will return base address and array length to the main.

allocate_array will have no argument IN and two arguments OUT:

$sp+0 - array base address (OUT)

$sp+4 - array length (OUT)

allocate_array will ask the user for the length of the array and will validate it to make sure array length is greater than 7 and odd. If an invalid length is entered,allocate_array will print an error message and re-prompt the user for the length. Whena valid length is entered, allocate_array will dynamically allocate exactly enough memory to hold the array (double precision floating point), then return base addressand array size to the create_array subprogram.

read_array will have two arguments IN and no argument OUT:

$sp+0 - array base address (IN)

$sp+4 - array length (IN)

read_array will read double-precision values into the array until the array is full. A prompt must be printed before each value is read.

print_array will have two arguments IN and no argument OUT:

$sp+0 - array base address (IN)

$sp+4 - array length (IN)

print_array will print all values from the array with each value separated by a space

print_every_nth will have three arguments IN and no argument OUT:

$sp+0 - array base address (IN)

$sp+4 - array size (IN)

$sp+8 - stride N (IN)

print_every_nth will print every nth value from the array (all elements have their index divisible by N, note that zero is divisible by any number). For example, consider the array [1.1, 2.5, 3.6, 4.8, 5.7, 6.4, 7.7, 8.7, 9.6].

For N = 3, the output would be [1.1, 4.8, 7.7].

For N = 4, the output would be [1.1, 5.7, 9.6].

If N 0, the subprogram will print an error message instead

get_sum will have two arguments IN and one argument OUT:

$sp+0 - array base address (IN)

$sp+4 - array length (IN)

$sp+8 - sum, double-precision (OUT)

get_sum will calculate and return the double-precision sum of all values in the array.

get_averages will have two arguments IN and no argument OUT:

$sp+0 - base address of array (IN)

$sp+4 - length of array (IN)

get_averages will call get_sum to get the sum of array. It will then calculate and printthe average of the array.

Requirements:

Arguments MUST be passed on the system stack AT THE SPECIFIED OFFSETS.

The stack must be used ACCORDING TO CONVENTION (even in main).

Subprograms SHOULD NOT access labels from another subprograms data section.

Download and use [subprogram_template.s] from D2L

Write sufficiently enough comments, subprogram description and do not forget to fill register usage section and argument IN & OUT section of [subprogram_template.s]

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Subtract and simplify: x / x2 - 1 - 3 / x2 + 4x - 5.

Answered: 1 week ago

Question

How might the lack of diversity at Roygbiv be explained?

Answered: 1 week ago

Question

=+4 What are non-union workers representations?

Answered: 1 week ago