Question: THIS IS A PROJECT IN MY COMPUTER ARCHITECTURE CLASS. NEEDS TO BE CODED IN MIPS ASSEMBLY. JUST ADD CODE TO EXISTING FILL WHERE THE COMMENTS

THIS IS A PROJECT IN MY COMPUTER ARCHITECTURE CLASS. NEEDS TO BE CODED IN MIPS ASSEMBLY. JUST ADD CODE TO EXISTING FILL WHERE THE COMMENTS TELL YOU TO.

In this project, please complete the attached code project3.asm to achieve the following functions: 1) Read in a sequence of numbers from the console one by one 2) If a special number "99999" is read in, it indicates the end of the input and this number "99999" is not counted as an input number. 3) For each input number, decide whether it is even or odd. If it is even, store to the EvenArray sequentially. If it is odd, store to the OddArray sequentially. 4) Print out all the odd numbers in the OddArray and all the even numbers in the EvenArray. In the current project3.asm, I have done 1) and 2) for you and all you need to do is 3) and 4). Keep in mind that either EvenArray or OddArray or even both may be empty. Your code should function correctly for these cases. Read the file project3.asm carefully and thoroughly before working on this project. You can revise the code I provided if you need. Submit your completed code to the dropbox and make sure it compiles and runs correctly in Mars. An example results: Input a Number:(99999 indicates the end) 12 Input a Number:(99999 indicates the end) 34 Input a Number:(99999 indicates the end) 2 Input a Number:(99999 indicates the end) -9 Input a Number:(99999 indicates the end) 0 Input a Number:(99999 indicates the end) 45 Input a Number:(99999 indicates the end) 978652 Input a Number:(99999 indicates the end) -44 Input a Number:(99999 indicates the end) 99999 Odd #'s:, -9, 45 Even #'s:, 12, 34, 2, 0, 978652, -44 -- program is finished running --

project3.asm

.data OddArray: .space 100 EvenArray: .space 100

string1: .asciiz "Input a Number: " string2: .asciiz " Odd #'s:" string3: .asciiz " Even #'s:" string4: .asciiz ", "

.text main: addi $s2, $zero, 99999 # Indicator for stop input new number addi $s3, $zero, 0 # Initialize # of input odd numbers addi $s4, $zero, 0 # Initialize # of input even numbers la $s5, OddArray # BaseAddress of Odd Array la $s6, EvenArray # BaseAddress of Even Array # Read input number until 99999 is input. 99999 is the indicator of the end and it will not be counted as an input number. InputLoop: addi $v0, $zero, 4 # code for printing string is 4 la $a0, string1 # load address of string to be printed into $a0 syscall # call operating system addi $v0, $zero, 5 # code for reading integer is 5 syscall # call operating system add $s1, $v0, $zero # input into $s1 beq $s1, $s2, ExitLoop # No more input if 99999 is input # You write code here to decide whether the input is odd or even # If it is odd, store into the odd array, move to the next space and increase $s3, the count of the odd numbers. # If it is even, store into the even array, move to the next space and increase $s4, the count of the even numbers. # WRITE CODE HERE j InputLoop

ExitLoop: addi $v0, $zero, 4 # code for printing string is 4 la $a0, string2 # load address of string to be printed into $a0 syscall # You write the code here to print out the odd numbers in the OddArray. This is basically a for loop over $s3 elements in OddArray. # The printed numbers are separted by ', ' as in string4 defined above. addi $v0, $zero, 4 # code for printing string is 4 la $a0, string3 # load address of string to be printed into $a0 syscall # You write the code here to print out the even numbers in the EvenArray. This is basically a for loop over $s4 elements in EvenArray. # The printed numbers are separted by ', ' as in string4 defined above. # WRITE CODE HERE # exit addi $v0, $zero, 10 syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!