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...
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...
This is JAVA PROGRAMMING Sort the contents of the two files in ascending order and combine...
This is JAVA PROGRAMMING Sort the contents of the two files in ascending order and combine them into one new file (words.txt). When comparing string order, you must use the compareTo method and make an exception.The source code below is a code that only combines files. Use the comparedTo method to sort the contents of the two files in ascending order.(ex. if(str1.compareTo(str2)<0) {}) <file1.txt> at first   castle   consider   considerable   enlighten   explain   explanation   female   <file2.txt> consideration   considering that   education   educational   endow  ...
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...
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...
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data...
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data columns in customer-status.txt (separated by comma): Account Number, Name, Status 527099,Sanford and Sons,bronze Data columns in sales.txt (separated by comma): Account Number, Name, SKU, Quantity, Unit Price, Ext Price, Date 163416,Purdy-Kunde,S1-30248,19,65.03,1235.57,2014-03-01 16:07:40 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01 After you combine, you will see the following: 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01,bronze
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT