Do Not Use Pseudo Insturctions or li la instructions, etc... Write and test a MIPS program consisting...

80.2K

Verified Solution

Question

Electrical Engineering

Do Not Use Pseudo Insturctions or li la instructions,etc...

Write and test a MIPS program consisting of four functions. Inthe following descriptions, the symbol & means “addressof”.

void main(): The main function must 1) print your name 2) callthe readData function 3) call count function 4) complete theprogram. The main function must set up all parameters beforecalling each of the functions.

int readData (&array): The starting address of an array ispassed to the function as a parameter using $a0. The function mustprompt for and read and store integers in the array until either azero is entered or 10 numbers are read. Once the tenth integer isentered, your program must stop reading. The function must return(using $v0) the number of values read and stored in the array (10or less). The zero input is not part of the array and mustnot be stored in the array. If the first input isa zero, then the array will be empty and the count returned iszero.

float average (&array, count): The starting address of anarray (in $a0) and the number of integers stored in the array (in$a1) are passed to the function. The purpose of the function is tocalculate and return (using $f0) the floating point average of thenumbers. To find the average, sum all the integers together andthen divide by the count as a floating point value. If the count iszero, return 0.0. Use appropriate registers for the parameters andthe return value.

void count (&array, count): The starting address of an array(in $a0) and the number of integers stored in the array (in $a1)are passed to the function. The function determines how many of theintegers in the array are greater than or equal to the average.First the parameters for the average function are set and thenaverage function is called to determine the average value. Thereturned value is then printed. Then each value in the array istested to determine if its value is greater than or equal to theaverage. The count of the values greater than or equal to theaverage is then printed.

Example input and output:

Linda Chatting
Enter a number 3
Enter a number 6
Enter a number 2
Enter a number 4
Enter a number 0
The average is 3.750000000
There are 2 numbers greater than or equal to the average.

In addition,

 Functions must be called using jal and return using jr.

 Parameters must be passed as specified and used correctly. ThereadData, average and count

functions must access the array through the parameter, notdirectly.

 Be sure to comment all instructions. All functions mustinclude comments describing the

function and its parameters and return value (if any). Be surethat your name and class ID appear at the beginning.

Answer & Explanation Solved by verified expert
4.0 Ratings (468 Votes)
comm arr404 comm i44 rdata align 2 LC0 ascii d000 text align 2 globl read set nomips16 set nomicromips ent read type read function read frame fp3231 vars 0 regs 20 args 16 gp 8 mask 0xc00000004 fmask 0x000000000 set noreorder cpload 25 set nomacro addiu spsp32 sw 3128sp sw fp24sp move fpsp cprestore 16 movz 31310 sw 432fp lw 2goti28 nop sw 002 b L2 nop L4 lw 2goti28 nop lw 202 nop    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students