Question: part A .data array: .word 0, -4, 3, -7, -10, 10, -5, 4, 7, -9 # array of words to contain fib values .word
part A "
.data
array: .word 0, -4, 3, -7, -10, 10, -5, 4, 7, -9 # "array" of words to contain fib values
.word -1, 10, -9, 0, 6, 3, -5, 2, -4, -0 # "array" of words to contain in fib value
size: .word 20 # size of "array"
max: .word 0
.text
main: la $t1, array # load address of array la $t3, size # load address of size variable lw $t3, ($t3) # get value from array lw $s0, ($t1) # max set to array[0] addi $t1, $t1, 4 # increment address of Fib. number source addi $t3, $t3, -1 # decrement loop counter MAX_LOOP: lw $t5, ($t1) # get value from $t1 and stores word in $t5 ble $t5, $s0,NEXT # if max is less then array element switch to NEXT move $s0, $t5 # save max to array NEXT: addi $t3, $t3, -1 # decrement loop counter addi $t1, $t1, 4 # increment address of Fib. number source bnez $t3, MAX_LOOP # branch to MAX_LOOP if (max
Please do all parts. Don't do PART A i got it DONE
The description asked you to reorganize the loop so it can be accomplished with one branch instruction instead of two.. If your naive version is already implemented in one branch instruction, you don't need to optimize your code further; just reuse your loop and focus on pointer-based implementation. You still have additional branch instruction for implementing the if condition within the loop.

1. [100pts] The following program (written in C) finds the maximum value of an array int max, 1j max = array[0]; for (i=0; i size; i++) if ( max array[1] ) max = array[1]; 1.a [50pts] Implement the above C routine in the MIPS assembly language. This part should be written without any urge for optimization 1.b [50pts] Carry out the following optimizations on your program [1525pts] Reorganize the loop so it can be accomplished with one branch instruction instead of two . [4025pts] Replace the array subscripting with pointers as illustrated in the "Arrays versus Pointers section of the text. Instructions: Use the following sample dataset to finish your implementation 0 -4 3 -7 -10 10 -5 47 -9 -1 10 -9 0 6 3 -5 2-4 -0 You might need to define array in the text segment shown below data array: .word , -4, 3, -7, 10, 10, -5, 4, 7,-9 .word -1, 10, -9, 0, 6, 3, -5, 2, -4, -0 Also, in your text segment, you have to load the address of array by using "la $t1, array" From there, you should be able to implement your algorithm. 1. [100pts] The following program (written in C) finds the maximum value of an array int max, 1j max = array[0]; for (i=0; i size; i++) if ( max array[1] ) max = array[1]; 1.a [50pts] Implement the above C routine in the MIPS assembly language. This part should be written without any urge for optimization 1.b [50pts] Carry out the following optimizations on your program [1525pts] Reorganize the loop so it can be accomplished with one branch instruction instead of two . [4025pts] Replace the array subscripting with pointers as illustrated in the "Arrays versus Pointers section of the text. Instructions: Use the following sample dataset to finish your implementation 0 -4 3 -7 -10 10 -5 47 -9 -1 10 -9 0 6 3 -5 2-4 -0 You might need to define array in the text segment shown below data array: .word , -4, 3, -7, 10, 10, -5, 4, 7,-9 .word -1, 10, -9, 0, 6, 3, -5, 2, -4, -0 Also, in your text segment, you have to load the address of array by using "la $t1, array" From there, you should be able to implement your algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
