Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please giving me the complete the code of this Project !! i nedd complete CODE CODE!!!!!!! In this project, please complete the attached code project3.asm

Please giving me the complete the code of this Project !! i nedd complete CODE CODE!!!!!!!

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 --

.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. 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. # exit addi $v0, $zero, 10 syscall

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions