Question

In: Computer Science

This assignment worth 10% of your total course grade. Write spim program and execute it on...

This assignment worth 10% of your total course grade. Write spim program and execute it on
mars. Your program reads two integer values x, y. Both x and y must be single digit number > 0.
If the user does not enter a value that meets this condition ask the user to enter a new value
again. Also Write two functions. The first function call it SumEven that gets x and y passed as
parameters and returns the sum of even values between x and 10*y inclusive. Also write
another function call it Factorial that gets |y-x| (absolute value of y-x) as a parameter and
returns the factorial of this value. Before you exit your program Must print both values
returned on the screen a long with your name.
Input:
Enter first number: x if x is not single didit ask fox another value
Enter second number y if y is not single digit ask for another value
Output:
Your Name
The value returned by SumEven
The value returned by Factorial.

Mips Languages

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

code.asm

.data
prompt: .asciiz "\nPlease enter first number : "
prompt1: .asciiz "\nPlease enter second number : "
errMsg: .asciiz "\nPlease enter single digit number"
sumEvenMsg: .asciiz "\nSum of even number is : "
factMsg: .asciiz "\nThe result of factorial is : "
.globl main
.text
main:
askFirst:
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,5
syscall #ask user input
move $t1,$v0 #save a to t1
bgt $t1,10,error1
blt $t1,0,error1
j next
error1:
li $v0,4
la $a0,errMsg #it will print prompt
syscall
j askFirst
next:
askSecond:
li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0,5
syscall #ask user input
move $t2,$v0 #save a to t1
bgt $t2,10,error2
blt $t2,0,error2
j next2
error2:
li $v0,4
la $a0,errMsg #it will print prompt
syscall
j askSecond
next2:

move $a0,$t1
move $a1,$t2
jal sumEven

move $t0,$v0
li $v0,4
la $a0,sumEvenMsg #it will print prompt
syscall
move $a0,$t0
li $v0,1
syscall

move $a0,$t1
move $a1,$t2
jal Factorial
move $t0,$v0
li $v0,4
la $a0,factMsg #it will print prompt
syscall
move $a0,$t0
li $v0,1
syscall

li $v0,10
syscall

sumEven:
li $v0,0
mul $a1,$a1,10 #get b*10
loop:
div $t0,$a0,2
mfhi $t0
bne $t0,0,skipOdd
add $v0,$v0,$a0
skipOdd:
add $a0,$a0,1 #
ble $a0,$a1,loop
jr $ra

Factorial:
sub $t3,$a0,$a1
bgt $t3,0,skipNeg
mul $t3,$t3,-1 #get abs value
skipNeg:
li $t0,1
li $v0,1
loop2:
mul $v0,$v0,$t0
add $t0,$t0,1
ble $t0,$t3,loop2
jr $ra


Related Solutions

Assignment 2 (worth 10% of the final course grade - due date July 23, 2019) Prof....
Assignment 2 (worth 10% of the final course grade - due date July 23, 2019) Prof. Sherif Saad Purpose The purpose of this assignment is to help you to practice working with C String, arrays, and pointers Learning Outcomes ● Develop skills with pointers ● Learn how to traverse C String using pointers ● Passing Strings to functions ● Manipulate C String ● Develop algorithm design skills Problem Overview You will implement a basic string manipulation library called xstring.h. This...
Your participation and report on this project will be worth 20% of your course grade. The...
Your participation and report on this project will be worth 20% of your course grade. The assignment that you select should be a minimum of 1000 words in length. Title page, and bibliography are also needed. Find out the position or teaching held by your home church on the following issues: premarital sexual activity masturbation homosexual orientation homosexual behavior
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM ET of week 7. Instructions There are many tools available to assist you as an RN to organize your thoughts, make nursing judgments, and implement the 5 rights of delegation. SBAR – Situation, Background, Assessment, and Recommendation, is a standardized tool used in many institutions that provides a framework to facilitate clear communication between health care providers. The components of SBAR are as follows,...
Assignment Description: Write a C++ program for keeping a course list for each student in a...
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object that contains the student id (four digit integer), name (string), and a list of courses completed by the student. The course taken by a student are stored as a linked list in which each node contain course name (string such as CS41, MATH10), course unit (1 to 4) and the course grade (A,B,C,D,F)....
Group Project - “Raising capital through Crowdfunding” This project is worth 30% of your total grade....
Group Project - “Raising capital through Crowdfunding” This project is worth 30% of your total grade. The objective of this project is for each group to analyze the mechanism of crowdfunding, which has become popular as a major source of worldwide financing, especially for start-up businesses. Crowdfunding combines the best of crowd sourcing and micro-financing, bringing together various individuals who commit money to projects and companies they want to support. It’s a young and quickly growing market and it's transforming...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a 7 day period. Ask the user for the number of bugs collected on each day, and using an accumulator, keep a running total of the number of bugs collected. Display the total number of bugs collected, the count of the number of days, and the average number of bugs collected every day. Create a constant for the number of days the bugs are being...
Using C Write a program that will serve as a simple shell. This shell will execute...
Using C Write a program that will serve as a simple shell. This shell will execute an infinite for loop. In each iteration of the loop, the user will be presented with a prompt. When the user enters a command, the shell will tokenize the command, create a child process to execute it and wait for the child process to be over. If the user enters an invalid command, the shell should recognize the situation and show a meaningful message....
write a Java program Write a program to assign a letter grade according to the following...
write a Java program Write a program to assign a letter grade according to the following scheme: A: total score >= 90 B: 80 <= total score < 90 C: 70 <= total score < 80 D: 60 <= total score < 70 F: total score < 60 Output - the student's total score (float, 2 decimals) and letter grade Testing - test your program with the following input data: test1 = 95; test2 = 80; final = 90; assignments...
Write a JAVA program to display your complete names, your matric number and your course of...
Write a JAVA program to display your complete names, your matric number and your course of study, using the two access modifiers stated in (a) and (b) (a) Use static access modifier for the method declaration of the program class, also use class name Eee532MakeUp. Use any method name of your choice. (b) Use public access modifier for the method declaration of the program class, also use class name EceCourseJava. (2) Which of the programs in (a) or (b) is...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade and the program will determine if that grade is an A, B, C, D, or E. The student can only enter number 0-100. A = 90-100 B = 80-89 C = 70-79 D= 60-69 E = 59 or less Save the file as Lab3.4 and submit the file. Use https://repl.it/ THIS LANGUAGE IS PYTHON Thank you :)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT