Question

I need help with this MIPS program. Write a program that makes an array of integers...

I need help with this MIPS program.

Write a program that makes an array of integers called array in the .data section. It should print the number of zeroes in that array. You should also have a variable called array_size in the .data section which is set to the number of elements in your array. Let's say you name your program count_zeroes.s. To submit your program, you must upload it to hills and run the following command (assuming you are in the same directory as your program):

0 0
Add a comment Improve this question Transcribed image text
Answer #1

data:

add $t0,$s0,zero #initialize $t0=$s0,$s0 is array

sll $t1,$s1,2 #t1 contains 4*n each integer takes 4 bytes

add $t1,$t1,$s0 #$t1 contains $s0+4n getting last element to stop the loop

add $t2,$zero,$zero #number of zeros initialized to zero

Start: #start of loop

lw $t3,0($t0) #read a word from array

bne $t3,$zero,NotZero #skip increment if value not zero go to NonZero label

addi $t2,$t2,1

NotZero: addi $t0,$t0,4 #$t0 has next element address

bne $t0,$t1,start #checking last element address and if not equal branch to start label

End: <exit>

Add a comment
Know the answer?
Add Answer to:
I need help with this MIPS program. Write a program that makes an array of integers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A. Write an Array Program Write a main program that counts the number of occurrences of...

    A. Write an Array Program Write a main program that counts the number of occurrences of the number 6.0 in a large array of doubles and then prints out the number of elements in the array and the number of values that are 6.0. Also, compute and print the average value to 7 decimal places of all the elements in the array. 1. Use a for loop. The array fArray [ is defined in a file called Lab8Adatasetx.h that will...

  • write a MIPS program that does the following Create an array of 10 INTEGERS.  Create procedures to...

    write a MIPS program that does the following Create an array of 10 INTEGERS.  Create procedures to find the largest, and find the smallest. Create another procedure called range, which is the difference between largest and smallest (range should call findLargest and findSmallest) Convert your find largest procedure to be recursive

  • # ECE 445 Computer Organization # Homework 3, problem 9 # Write a MIPS assembly language...

    # ECE 445 Computer Organization # Homework 3, problem 9 # Write a MIPS assembly language program to count the number of positive values in an array of integers. # The array of integers and the array length are provided in the .data section below. # After running your code, the variable count (in memory) should contain the number of positive values in the array Insert your name here > Insert the date here > # Author: # Date: .text...

  • Introduction: In this lab, you will write a MIPS program to read in (up to) 50...

    Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...

  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • MIPS CODE required to write an assembly program to find the maximum of an array of integers by...

    required to write an assembly program to find the maximum of anarray of integers by doing the following:1. Prompt user to input array size n (n <= 10)2. Prompt user to input element values of array A one by one3. Display the result on the console.This program must at least include one function. The main program will read the valuesof the array (as user inputs the element values) and stores them in the memory (datasegments section) and at the end...

  • Please write a MIPS program to prompt the user to input three positive integers and then print out their greatest common prime factor.

    Please write a MIPS program to prompt the user to input three positive integers and then print out their greatest common prime factor.What to submit:1. Your MIPS program file.2. The log file of simulation in SPIM. The log file should contain the Registers,  Text Segments, Data Segments, and Console.

  • Hi, I need help with this MIPS Problem. Thanks! (2 pts) Modify your program from exercise...

    Hi, I need help with this MIPS Problem. Thanks! (2 pts) Modify your program from exercise 1. Now, instead of having the variables x and y in your .data section, you should ask the user for two numbers. Each time you ask for a number, you should print: Enter number: You should add the two numbers typed at the console and print the sum. In this program, you'll need to make use of system calls 1, 4, and 5. I...

  • Write a c program to implement threads. Accept an array of 40 integers, write a thread...

    Write a c program to implement threads. Accept an array of 40 integers, write a thread method named sum of array elements. Divide the array into 4 equal elements and call threads to find the sum of each part. Store the sum in a variable called “arrays'. Print the sum in the main function. (10 points)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT