Question: 1) need help writing A program that hard codes one FP value, reads in another from the user, multiplies them together, and prints the result.
1) need help writing A program that hard codes one FP value, reads in another from the user, multiplies them together, and prints the result.
Do the same thing, but for double precision
Working with unsigned integers, look at what happens when you multiply two numbers together that get you a result larger than 2^32, and write code that will detect the overflow in the 'hi' register
2) also need help writing a Code that creates an array of 5 elements, populates it, and then prints off the elements.
3)
Modify the following program to work on a 4x4 array and show that it works.
.data
# the next two lines define an array (mdArray as a 2x2 multidimensional array)
mdArray: .word 2,5
.word 3,7
size: .word 2 #dimension of the array (2x2 in this case, note this is only for square matrices)
.eqv DATA_SIZE 4 # number of bytes per element, 4 for ints, 1 for chars, 8 for doubles
.text
main:
la $a0, mdArray # base address
lw $a1, size # size
jal sumDiagonal #sum of diagonals, in our starting example, this is 9.
move $a0, $v0 # this is because sumDiagonal will return it's last value in $v0
li $v0, 1
syscall
#and done
li $v0, 10
syscall
sumDiagonal:
li $v0,0 #sum =0
li $t0,0 #t0 as the index
sumLoop:
#The next 4 lines are the bit you need to derive and fill in yourself
mul
add
mul
add
lw $t2, ($t1) #getting element
add $v0, $v0, $t2 # sum = sum + mdArray[i][i]
addi $t0, $t0, 1 # i = i+1
blt $t0, $a1, sumLoop #if i < size, loop again
jr $ra #ends sum diagonal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
