Question

Write MIPS program: That finds the maximum of 4 numbers. You should also consider what would...

Write MIPS program: That finds the maximum of 4 numbers. You should also consider what would happen if your function were provided some inapplicable parameters.

Absolute Value (x) = |x|

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data

txt1:   .asciiz   "Please enter apositive integer (negative integer to exit) : "

txt2:   .asciiz   "\nThe maximum value is : "

.text

.globl main

main:

    addi $s0, $zero, 0

loop:

    la $a0, txt1

    li $v0, 4

    syscall

   

    li $v0, 5

    syscall

   

   

    add $s0, $v0, 0

    add $t0, $t0, 1

    add $t3, $t3, $s0

   

    beq $t0, 1, first

  

    bgt $s0, $t1, max

first:

     add $t1, $s0, 0

     add $t2, $s0, 0

     j   loop

max:

    add $t1, $s0, 0

    j   loop   

print:

   la $a0, txt2

    li $v0, 4

    syscall

   

    add $a0, $t1, 0

    li $v0, 1

    syscall

   

   

    add $a0, $t1, 0

    li $v0, 1

    syscall

   

        

    add $a0, $t7, 0

    li $v0, 1

    syscall

            

exit:

    li $v0, 10

    syscall

Add a comment
Know the answer?
Add Answer to:
Write MIPS program: That finds the maximum of 4 numbers. You should also consider what would...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • MIPS Programming 1 In this project, you are going to write a MIPS program to read...

    MIPS Programming 1 In this project, you are going to write a MIPS program to read an integer number and convert it to 8- bit signed binary in a string. Your program should do the followings: Part II (50%, due date: March 1) for negative number . Write a non-leaf function to convert a negative integer number to 2's complement in string . Two parameters: integer number, string array or pointer -Get absolute value of the negative number o Call...

  • Write a MIPS assembly program to calculate nCr. The program should accept the numbers n and...

    Write a MIPS assembly program to calculate nCr. The program should accept the numbers n and r from the user. The program should call the factorial function. nCr = n! / ((n-r)! * r!) If n<r print an error message "n should not be less than r: re-enter the values." and get the inputs n and r from the user.

  • Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds...

    Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds the sum and average of a series of numbers he program should first prompt the user to enter total numbers of numbers are to be summed and averaged. It should then as for input for each of the numbers, add them, and print the total of the numbers and their average 2. Write a progra m that finds the area of a circle. The...

  • Write a program in C++ language that finds the largest number in an array of positive...

    Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...

  • Please write MIPS program that runs in QtSpim (ex: MipsFile.s) Write a MIPS program that will...

    Please write MIPS program that runs in QtSpim (ex: MipsFile.s) Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base and print out the decimal value; you must implement a function (which accepts a base and an address for a string as parameters, and returns the value) and call the function from the main program. The base will be given in decimal and will...

  • Write a program that finds and output all of the prime numbers between 2 to 2000...

    Write a program that finds and output all of the prime numbers between 2 to 2000 to the display screen. You are to declare any required array in main and pass them to your function sieve that will process the array.C++

  • Write a MIPS math quiz program in MARS. The program should start with a friendly user...

    Write a MIPS math quiz program in MARS. The program should start with a friendly user greeting. From there, it should generate a random arithmetic problem. Your program will need to generate three random things: the first and second operand and the operator to use. Your program should generate random positive integers no greater than 20 for the operands. The possible operators are +, -, * and / (division). The user should be prompted for an answer to the problem....

  • Write and test a MIPS assembly language program to compute and display the first prime numbers...

    Write and test a MIPS assembly language program to compute and display the first prime numbers up to n where n is given. Set n to be 19 but the program should work of any value of n. For the program to identify primes, the easiest way is to use the algorithm: for (i = 2; i < x; i++)       if ((x % i) == 0) break;   //break out, not prime where x is the number you are checking...

  • MIPS CODE required to write an assembly program to find the maximum of an array of integers by...

    required to write an assembly program to find the maximum of anarray of integers by doing the following:1. Prompt user to input array size n (n <= 10)2. Prompt user to input element values of array A one by one3. Display the result on the console.This program must at least include one function. The main program will read the valuesof the array (as user inputs the element values) and stores them in the memory (datasegments section) and at the end...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT