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
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for...
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for CIS 1100 are calculated based on two assignments, a midterm exam, and a final exam. Here are the weights of these. Assignments 25% Midterm exam 35% Final exam 40% Ask the user for the scores they received for the two assignments, midterm exam, and the final exam. Then calculate and display their total weighted score they received for the course. Based on the weighted...
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...
Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
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...
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....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT