3. Write a MIPS code that finds the highest value, lowest value and average of 10 numbers that are given as the global values (in the address range: 0×10000000 to 0×10000009) and stores them in the next addresses. Bonus (optional): Write a MIPS code module to sort the numbers in ascending order. Mention your sorting algorithm clearly.
MIPS PROGRAM:-
.data
.text
main:
#$s0 = stores the address
#$s1 = min
#$s2 = max
#$s3 = average
li $s0, 0
lui $s0, 0x1000
li $s3, 0
#considering first address value to be min and max
lw $s1, 0($s0)
add $s2, $zero, $s1
add $s3, $zero, $s1
li $t0, 9 #count
loop:
addi $s0, $s0, 1
ble $t0, $0, LOOP_END
lw $t1,0($s0)
add $s3,$s3, $t1
bge $s1, $t1, SKIP_MIN
add $s1, $zero, $t1
SKIP_MIN:
ble $s2, $t1, SKIP_MAX
add $s1, $zero, $t1
SKIP_MAX:
addi $t0, $t0, -1
j loop
LOOP_END:
sw $s1,0($s0) #stored min in
0x1000000A
addi $s0, $s0, 1
sw $s2,0($s0) #stored min in
0x1000000B
addi $s0, $s0, 1
li $t1,10
div $s3, $t1
mflo $s3
sw $s3,0($s0) #stored avg in
0x1000000B
Done:
li $v0, 10 #syscall to exit
syscall
3. Write a MIPS code that finds the highest value, lowest value and average of 10...
Write a MIPS code that finds the highest value, lowest value and average of 10 numbers that are given as the global values (in the address range:0×10000000 to 0×10000009) and stores them in the next addresses and write a MIPS code module to sort the numbers in ascending order. Mention your sorting algorithm clearly.
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...
Directions: Problem 1: Write (using pen-and-paper rather than code) the list after each pass of quick and merge sort for the following list of numbers. Assume that you are sorting the numbers into ascending order. For quick sort, assume that the first number from the sublist is chosen as the pivot. 54 17 21 18 4 7 19 41 Problem 2: Write the list after each pass of the quick sort algorithm for the following list of numbers, using the...
Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...
Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction in hexadecimal. The opcode for sw 43 (101011). sw St1, -4(St3) Question 4 (10 points) Consider the following MIPS assembly code: addi $s3, $0, 5 addi $s1, S0, 3 addi Ss1, $s1, 2 beq Ss3, Ssl, target addi Ss1, Ss1, 1 target: add Ss3, Ss1, Ssl a. After running the code, what is the value of Ss3? b. If the memory address of the...
So the assignment is to write a program that have the user entered 3 numbers and than it will sort it by ascending order. Here are the code I wrote, but it won't compiled and I kept on getting an error message "Using uninitiazed memory" for all the variables. Can someone please help take a look and see whats going on? #include <iostream> using namespace std; int main() { //variables int num1, num2, num3; int lowest, middle, highest; //user inputs...
Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...
Python Code Write a program using functions and mainline logic which prompts the user to enter a number. The number must be at least 5 and at most 20. (In other words, between 5 and 20, inclusive.) The program then generates that number of random integers and stores them in a list. The random integers should range from 0 to 100. (You can use a wider range if you want, but the lower end of the range must be at...
Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the size of an array. Then create an integer array of that exact size. Ask the user to enter a maximum value and then write a loop to fill the array with random numbers with value in the range of 1 to the maximum value. For example, if the maximum value is 100, random numbers must have value 1 to 100 inclusive. Input size of...
Java Question:
Code the Merge Sort in such a way that it outputs the number of
comparisons and the number of swaps performed when sorting a random
set of items. Then use it to sort 1000, 5000, 10,000, and 100,000
integers. Tabulate the results and compare it to the number of
comparisons and swaps calculated using the formulas given in Table
8.6.
Table 8.6 Performance of the Quicksort Algorithm Speed Memory Overhead Range Bytes lgorithm Range Effort Comments Binary Tree...