Question: Write a MIPS assembly language program that does the followings: a ) Prompts the user for an integer in the range of 0 to 1

Write a MIPS assembly language program that does the followings:
a) Prompts the user for an integer in the range of 0 to 100. If the user inputs 0 the program stops. If the user inputs an invalid value (e.g.102) print an error message.
b) Otherwise, the program stores the numbers from 0 up to (the input value)*2 into an array of N+1 words in memory, i.e. initializes the array with values 0,2,6,8,... up to 2*N where N is the value that user has given. Show a screenshot of the data segment that confirms that 0 to 2*N are correctly stored in the memory. Hint: use the add instruction to get 2*N.
c) The program then adds the value of all numbers of the array together by loading them from the main memory then add them up, then prints out the sum with the message "The sum of double integers from 0 to N is:". For example, if the user gave 3 as the input the program prints out "The sum of double integers from 0 to 3 is 12".(0*2+1*2+2*2+3*2=12.)

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 Programming Questions!