Question

In: Computer Science

There are two programming questions for you to do. Please submit two.s or .asm files. You...

There are two programming questions for you to do. Please submit two.s or .asm files. You can use the usual settings as the previous homework. But if you want to use pseudo-instructions, you will need to uncheck "Bare Machine" and check "Accept Pseudo Instructions"

(10 points) Declare an array of integers, something like: . data size : . word 8 array : . word 23 , -12 , 45 , -32 , 52 , -72 , 8 , 13 Write a program that computes the sum of all the odd integers in the array. Put the sum in register $1

Solutions

Expert Solution

Given below is the code for the question. I have given 2 screenshots of before and after execution to show that the answer is stored in $1. (There will not be any output printed on screen)
Please do rate the answer if it helped. Thank you.

.data
size: .word 8
array: .word 23 , -12 , 45 , -32 , 52 , -72 , 8 , 13

.text
   lw $t0, size
   li $t1, 0
   li $t5, 0 #sum
loop:
   bge $t1, $t0, end_loop
   #calc offset and get num at offset
   mul $t2, $t1, 4
   lw $t3, array($t2)
  
   #check if odd by dividing by 2
   div $t4, $t3, 2
   mfhi $t4 #get remainder
   beq $t4, 0 , next #even
   add $t5, $t5, $t3
next:
   add $t1, $t1, 1
   b loop
end_loop:
   move $1, $t5
   #exit
   li $v0, 10
   syscall


Related Solutions

Please do both questions in MASM and complete these two in two separate files. 3. Summing...
Please do both questions in MASM and complete these two in two separate files. 3. Summing the Gaps between Array Values Write a program with an indexed addressing that calculates the sum of all the gaps between successive array elements. The array elements are doublewords, sequenced in nonde- creasing order. So, for example, the array {0, 2, 5, 9, 10} has gaps of 2, 3, 4, and 1, whose sum equals 10.      4. Copying a Word Array to a DoubleWord...
For this assignment you are expected to submit the following two files: 1. ????ℎ??????ℎ??????. ℎ 2....
For this assignment you are expected to submit the following two files: 1. ????ℎ??????ℎ??????. ℎ 2. ????ℎ??????ℎ??????. ??? You are being asked to write a class for simple weather data storage. Each instance of the class will hold data for exactly one month (30 days). Each day’s weather will be classified as either rainy (‘R’), cloudy (‘C’), or sunny (‘S’). To achieve this, your class will contain a character array of length 30. The class will provide three functions to...
Although the following questions ask you to draw diagrams, you do not have to submit these....
Although the following questions ask you to draw diagrams, you do not have to submit these. You do, however, need to know how to draw them. Suppose Apple has a monopoly on a new product, the iFraud. The market is characterized by:             Short Run Marginal Cost of Supply:             MC = 100 + 2Q             Short Run Average Total Cost:                      AC = 100 + Q + 150,000/Q             Marginal Willingness to Pay:                         P = 1600 – 4Q A....
Programming. Write only code for the following. Do not write any comments. You can submit your...
Programming. Write only code for the following. Do not write any comments. You can submit your answer as .java file(s). #1. Design a Java JProduct class for a product which implements both cloneable and comparable interfaces The class should have the following private member variables: m_id: an integer that holds the product ID m_name: a string that holds the product name m_wholesaleprice: a double that holds the wholesale price m_retailers: a String array that holds all retailers who sell the...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following:...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following: (1) the client and the server source files each (2) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identifiers suitable, to enable enhanced readability of the code. Problem: Write an ftp client and an ftp server such that the client sends a request to ftp server for downloading a file. The...
ASM Programming instructions: For this week the student’s goal is to write an occurrence finding function...
ASM Programming instructions: For this week the student’s goal is to write an occurrence finding function that builds off of the past two weeks of assembly programming. The requirements for this function are as follows. The user is allowed to type in 10 positive integers plus an occurrence value (meaning 11 inputs). The 10 integers should be handled in a loop where each value input by the user (as in week 1) is stored into memory in an array like...
PLEASE DO IN JAVA AND USING REPL.IT Below are the two files, boysNames.txt and GirlsNames.txt Write...
PLEASE DO IN JAVA AND USING REPL.IT Below are the two files, boysNames.txt and GirlsNames.txt Write a program that reads the contents of the two files into two separate arrays, or ArrayLists. The user should be able to enter a boy’s name, a girl’s name, or both, and the application will display messages indicating whether the names were among the most popular. BoyNames: Jacob Michael Joshua Matthew Daniel Christopher Andrew Ethan Joseph William Anthony David Alexander Nicholas Ryan Tyler James...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:    1. Artist.java (Given Below)    2. p7artists.java (Input file to read from)    3. out1.txt (Output file to write to) B. Java programs needed to writeand create:    1. MyArtistList.java:    - Contains the following:        1. list - public, Arraylist of Artist.        This list will contain all entries from "p7artists.txt"        2. Constructor:        A constructor that accepts one...
you need to submit the following files: Main.java Additionally, you need to download file ‘letter_count.csv’, that...
you need to submit the following files: Main.java Additionally, you need to download file ‘letter_count.csv’, that contains counts for characters in a text (see submission folder on iCollege) and put it into the root of related Eclipse project folder. To view your project folder through system file explorer, right-click on ‘src’ folder in the Eclipse project explorer and choose ‘Show In->System Explorer’. Consider the following Java code, that reads a .csv file: BufferedReader csvReader = new BufferedReader(new FileReader("letter_count.csv")); String currentRow...
For this assignment, please submit the answers to the following questions, as well as an Excel...
For this assignment, please submit the answers to the following questions, as well as an Excel spreadsheet which documents the work you did. Do poets die young? According to William Butler Yeats, “She is the Gaelic muse, for she gives inspiration to those she persecutes. The Gaelic poets die young, for she is restless, and will not let them remain long on earth.” One study designed to investigate this issue examined the age at death for writers from different cultures...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT