Question

In: Computer Science

MIPS code to calculate The 1- minimum 2- maximum 3- mid value of three number, user...

MIPS code to calculate The 1- minimum 2- maximum 3- mid value of three number, user will enter the numbers

Solutions

Expert Solution

2. Maximum of three numbers:

.text
.globl main

main:
# Display prompt1
li $v0, 4
la $a0, prompt1
syscall

# read keyboard into $v0 (number x is number to test)
li $v0, 5
syscall

# move the first number from $v0 in $t0
move $t0,$v0

# Display the prmopt2 (string)
li $v0, 4
la $a0, prompt2
syscall

# read keyboard into $v0 
li $v0, 5 
syscall

# move the second number from $v0 in $t1
move $t1,$v0 

# Display the prmopt3 (string)
li $v0, 4
la $a0, prompt3
syscall

# read keyboard into $v0 
li $v0, 5 
syscall

# move the third number from $v0 in $t2
move $t2,$v0

# Display the prmopt4 (string)
li $v0, 4
la $a0, prompt4
syscall

# read keyboard into $v0 
li $v0, 5 
syscall

# move the fourth number from $v0 in $t3
move $t3,$v0


# effectively these two lines do: $t1 = max($t0, $t1)
bge $t1, $t0, CMP2
move $t1, $t0
CMP2:
# effectively these two lines do: $t1 = max($t2, $t1)
bge $t1, $t2, L1 
move $t1, $t2

# largest number in $t1  
move $t2, $t0       

# print answer 
L1: 
li $v0, 4 
la $a0, answer
syscall

# print integer function call 1 
# put the answer into $a0
li $v0, 1 
move $a0, $t1 
syscall

#exit
end: li $v0, 10 
syscall 

.data
prompt1:
 .asciiz "Enter the first number "
prompt2:
 .asciiz "Enter the second number "
prompt3:
 .asciiz "Enter the third number "
prompt4:
 .asciiz "Enter the fourth number "
answer:
 .asciiz "The largest number is "

1. Minimum of three numbers:

.data
Msg1: .asciiz "Enter the first integer: "
Msg2: .asciiz "Enter the second integer: "
Msg3: .asciiz "Enter the third integer: "
Msg4: .asciiz "the the smallest numberis: "

.text
     # Print the first message
 li $v0, 4
 la $a0, Msg1
 syscall

 # Prompt the user to enter the first integer
 li $v0, 5
 syscall

 # Store the first integer in $t0
 move $t0, $v0
# Print the second message
 li $v0, 4
 la $a0, Msg2
 syscall

 # Prompt the user to enter the second integer
 li $v0, 5
 syscall

 # Store the first integer in $t1
 move $t1, $v0

 # Print the third message
 li $v0, 4
 la $a0, Msg3
 syscall
# Prompt the user to enter the third interger
 li $v0, 5
 syscall

 # Store the first integer in $t0
 move $t2, $v0

 # Determine the smallest Number
 slt $s0, $t1, $t0
 beq $s0, $zero, L1

Related Solutions

Write a program/code that prompts the user for a minimum min and a maximum max. Then...
Write a program/code that prompts the user for a minimum min and a maximum max. Then use these values to print the squares of all even numbers between the min and max variables. (WRITTEN IN C) For example if the user enters 6 as the minimum and 200 as the maximum, the program/code should print the following. Enter limit on minimum square: 6 Enter limit on maximum square: 200 36 64 100 144 196
Write code in MIPS ,read tow number from the user that do the following: 1- multiply...
Write code in MIPS ,read tow number from the user that do the following: 1- multiply 2- Dividing 3- sum 4- average 5- minimum 6- maximum 7- print message to thank the user for using my program
Write a C program/code that prompts the user for a minimum min and a maximum max....
Write a C program/code that prompts the user for a minimum min and a maximum max. Then use these values to print the squares of all even numbers between the min and max variables. For example if the user enters 6 as the minimum and 200 as the maximum, the program/code should print the following. Enter limit on minimum square: 6 Enter limit on maximum square: 200 36 64 100 144 196
Write a mips assembly code program that ask the user to enter an integer value, and...
Write a mips assembly code program that ask the user to enter an integer value, and then print the result of doubling that number.
1-f(x) =1/8(7x-2), x ≤ 3 a-absolute maximum value b-absolute minimum value c-local maximum value(s) d-local minimum...
1-f(x) =1/8(7x-2), x ≤ 3 a-absolute maximum value b-absolute minimum value c-local maximum value(s) d-local minimum value(s) 2-Show that the equation x3 − 16x + c = 0 has at most one root in the interval [−2, 2]. 3-If f(1) = 10 and f '(x) ≥ 3 for 1 ≤ x ≤ 4, how small can f(4) possibly be?
Provide the Java code to compute the sum, average, maximum number and minimum number if I...
Provide the Java code to compute the sum, average, maximum number and minimum number if I have a string sentence of double numbers. Assume that the length of the string sentence is not known. It can be of any length. To split a string based on the comma character use the following. String sentence = "A,B,C,D,E"; String[] stringsArray = receivedSentence.split(","); Then stringsArray is an array of five elements such that: stringsArray[0] = 'A' stringsArray[1] = 'B' stringsArray[2] = 'C' stringsArray[3]...
1. Find the absolute minimum and maximum value of f(x) = x4 − 18x 2 +...
1. Find the absolute minimum and maximum value of f(x) = x4 − 18x 2 + 7 (in coordinate form) on [-1,4] 2. If f(x) = x3 − 6x 2 − 15x + 3 discuss whether there are any absolute minima or maxima on the interval (2,∞) show work please
(in java) Find the maximum value and minimum value in milesTracker. Assign the maximum value to...
(in java) Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 given code below (please bold the solution, thank you!) import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int...
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and...
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i; int j; int maxMiles; // Assign with first element in...
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and...
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 Java Code: Remember we can only add to the code. We cant change whats already given. Thank you. import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_ROWS = 2; final int NUM_COLS = 2;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT