MARS- MIPS Assembler and Runtime Simulator.
Step 1- program in Mips assembly
.data
prompt: .asciiz "\n Enter a number: " even_msg: .asciiz "\n The number is even.\n" odd_msg: .asciiz "\n The number is odd.\n" goodbye: .asciiz "\n If continew press Y\n" .text main: j loop loop: la $a0, prompt li $v0, 4 syscall # Read in value li $v0, 5 syscall # If number is negative, exit program. slt $t0, $v0, $zero bne $t0, $zero, exit # Call even_or_odd on value add $a0, $v0, $zero jal even_or_odd j loop even_or_odd: addi $t0, $zero, 2 # Set divisor to 2 div $a0, $t0 mfhi $t0 # Save remainder beq $t0, $zero, even j odd even: la $a0, even_msg li $v0, 4 syscall j return odd: la $a0, odd_msg li $v0, 4 syscall j return return: lw $t0, 0($sp) addi $sp, $sp, 4 jr $ra exit: la $a0, If continew press Y li $v0, 4 syscall li $v0, 10 syscall
Step 2- In this program first just message printed then function defined to check given no is even or odd.
please can you help me to solve it in Mips Assembly that works on Mars 4.5:...
ASSEMBLY LANGUAGE (Mars MIPS) Starting code: Factorial: #Factorial Recursive function subu $sp, $sp, 4 sw $ra, 4($sp) # save the return address on stack beqz $a0, terminate # test for termination subu $sp, $sp, 4 # do not terminate yet sw $a0, 4($sp) # save the parameter sub $a0, $a0, 1 # will call with a smaller argument jal Factorial # after the termination condition is reached these lines # will be executed lw $t0, 4($sp) # the argument I...
Can someone help me solve this MIPS question, it must be able to run on qtspim. Write a MIPS code which involves three functions: a. main b. poly C. Pow to compute the value of the polynomial given below for any value of x, as given by the user. f(x) = 3x + 2x4 - 5x +7-6 Your program must pass arguments to functions such as poly and pow and get return values from these functions. The input to the...
can someone please help me with this. I need to use java. Recursion Write and run a program that reads in a set of numbers and stores them in a sequential array. It then calls a recursive function to sort the elements of the array in ascending order. When the sorting is done, the main function prints out the elements of the newly sorted array Hint: How do you sort an array recursively? Place the smallest element of the array...
PROJECT 6 Functions You are to write a PYTHON program which: *Defines the following 4 functions: whoamI() This function prints out your name and lists any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and prints out a message indicating if the number is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one...
PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to: -define a recursive procedure/function and call it. -use syscall operations to display integers and strings on the console window -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9 if n <= 5 =...
I've been trying to do this and cant figure it out. Please help me with this whole code, especially the section that is highlighted. Thank you!! Write a complete Java program to do the following: The main program reads in and prints three bowling scores, scorel, Score2, and score3. then calls a series of methods to process these scores. It The main program calls a method validGroup() to determine if this set of three values forms a valid group. The...
This exercise is also from C++ How do I even figure this out? please help me solve so I can get the answer correctly! Question 28 10 pts (SHORT ANSWER) Define a function named findEvenOrOdd that has 1 int parameter: num. When the function is called, it should use an if/else statement -OR- conditional expression to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is...
Can someone help me with this problem. We're using microsoft visual studios and its from my assembly code language class. we're using this template in class from the lecture slides Write a program and verify it using visual studio that does the following: Use type, lengthof, and size to make your program more independent of the data type. 3) Write a program that first reads the message entered by the user and stores it in Myname. Then it prints the...
Can anyone help to solve this MIPS assembly language problem? Please help. Translate the fowlowwing C code to MIPS assembly language. void main() { int i, sum, begin, end; for(i=0; i < 5; i++){ scanf(“%d, %d”, &begin, &end); sum = accum_range(begin, end); printf(“sum[%d: %d] = %d\n”, begin, end, sum); } int accum_range(int a, int b){ return accum (b) - accum(a); } int accum(int final) { int sum = 0; for (int I = 1; I <= final; I = I...
Please help me figure out why my code is not working properly.I had thought my logic was sound but later found it will run one time through fine however if the user opts to enter another value it will always be returned as an error. #include <iomanip> #include <iostream> #include <cstdlib> using namespace std; int const TRUE = 1; int const FALSE = 0; // declares functions void GetZipcode(); void RunAgain(); int GetSum(char d1, char d2, char d3, char d4,...