Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# I will not only give the 1500 pts for this problem but an additional 1500 by s

ID: 3562028 • Letter: #

Question

# I will not only give the 1500 pts for this problem but an additional 1500 by sending the person with the best answer a link to an empty question. THIS CODE IS WORTH 3000 POINTs

You are tasked to use the same positive integers from Part A to also compute: g = [a+(a*b)+(a*b*c)] / max(a,b,c)

More formally, write MIPS code to output the result of above expression of g without using any built-in MIPS/MARS instructions for multiplication or division. The values already entered for Part A for a, b, and c shall be used. Output the value of g in {quotient with remainder} format as separate decimal integers. Indicate the denominator for the remainder.

Note: To receive credit, no multiplication, no division, and no shift instructions shall be used. Namely, none of { mul, mul.d, mul.s, mulo, mulou, mult, multu, mulu, div, divu, rem, sll, sllv, sra, srav, srl, srlv } or else a zero score will result. Thus, it is to compose your own division technique. In addition, use of a loop is required for credit to realize the division code. It part of the project points to design a way to realize division using a loop.

## I have the code for part a. it is pasted below with comments to make it easier to follow. I need the code to find max value and then do the division. any questions please ask.

.data
message: .asciiz "Enter three integrs seperated by Enter key value: "
message1: .asciiz " f_ten = "
message2: .asciiz " f_two = "
val_1: .word 0
val_2: .word 0
val_3: .word 0

.text

main :
#ask user for decimal entry.
li $v0,4                # load syscall print_string (4) into $v0.
la $a0,message               # load syscall print_string (4) into $v0.
syscall


# Read first integer and put in val_1
li $v0,5                # load syscall read_int (5) into $v0.
syscall
la $t1,val_1               #load value of $t1 into val_1
sw $v0,0($t1)               #load val_1 into $v0
add $a0,$0,$v0                #computing value of a by adding value in $v0 and 0, storing answer into $a0

# Read first integer and put in val_2
li $v0,5               #load syscall read_int inot $v0
syscall
la $t1,val_2               #load val_2 into $t1
sw $v0,0($t1)               #load val_2 into $v0
add $a1,$0,$v0                #computing calue of b by adding value in $v0 and 0, storing answer into $a1      
jal my_mul                #jump to my_mul to compute a*b
la $t1,val_1               #loading value in val_1 into $t1
lw $a0,0($t1)                #setting value of &a0 to value in $t1      
add $a3,$a0,$a2            # computing a + a*b      

# Read first integer and put in val_3
li $v0,5               #load syscall read_int to $v0
syscall
la $t1,val_3               #store val_3 in $t1
sw $v0,0($t1)               #store value of $v0 into effective memory word address
add $a0,$0,$v0                #computing value of c by adding c and 0, storing value into $a0

add $a1,$0,$a2               #storing value of a*b in $a1

jal my_mul               #jump to my_mul to solve for a*b*c

add $a3,$a3,$a2            # computing value of f = a + a*b + a*b*c
li $v0,4               #loading syscal print_string to $v0
la $a0,message1               #loading string from message1 into $a0
syscall

li $v0,1               #loading syscal to print_int to $v0
addi $a0,$a3,0               #loading value of f into $a0 by adding f and 0
syscall

li $v0,4               #loading syscal print_string to $v0
la $a0,message2               #loading string from message1 into $a0
syscall
li $v0,35               #loading syscal to print_int to $v0
addi $a0,$a3,0               #loading value of f into $a0 by adding f and 0
syscall

li $v0, 10               # load syscall exit (10) into $v0.
syscall      

my_mul:                #input in $a0,$a1 and output in $a2 = $a1*$a0
addi $a2,$0,0               #loading 0 into $a2
again:beq $a0,$0,end           #loop - branch to end if value in $a0 = 0
add $a2,$a2,$a1               #adding $a1 to $a2 over and over until end of loop     
subi $a0,$a0,1               #counter for $a0  
b again                   #other wise branch back to again
end:jr $ra                #jump to statemnt whos address is $ra in this case its back to line with "jal my_mul"

Explanation / Answer

.data
message: .asciiz "Enter three integrs seperated by Enter key value: "
message1: .asciiz " f_ten = "
message2: .asciiz " f_two = "
message3: .asciiz " max(a,b,c) = "
message4: .asciiz " g_ten = "
message5: .asciiz "("
message6: .asciiz "/"
message7: .asciiz ")"
val_1: .word 0
val_2: .word 0
val_3: .word 0
val_f: .word 0
val_max:.word 0

.text

main :
#ask user for decimal entry.
li $v0,4 # load syscall print_string (4) into $v0.
la $a0,message # load syscall print_string (4) into $v0.
syscall


# Read first integer and put in val_1
li $v0,5 # load syscall read_int (5) into $v0.
syscall
la $t1,val_1 #load value of $t1 into val_1
sw $v0,0($t1) #load val_1 into $v0
add $a0,$0,$v0 #computing value of a by adding value in $v0 and 0, storing answer into $a0

# Read first integer and put in val_2
li $v0,5 #load syscall read_int inot $v0
syscall
la $t1,val_2 #load val_2 into $t1
sw $v0,0($t1) #load val_2 into $v0
add $a1,$0,$v0 #computing calue of b by adding value in $v0 and 0, storing answer into $a1
jal my_mul #jump to my_mul to compute a*b
la $t1,val_1 #loading value in val_1 into $t1
lw $a0,0($t1) #setting value of &a0 to value in $t1
add $a3,$a0,$a2 # computing a + a*b

# Read first integer and put in val_3
li $v0,5 #load syscall read_int to $v0
syscall
la $t1,val_3 #store val_3 in $t1
sw $v0,0($t1) #store value of $v0 into effective memory word address
add $a0,$0,$v0 #computing value of c by adding c and 0, storing value into $a0

add $a1,$0,$a2 #storing value of a*b in $a1

jal my_mul #jump to my_mul to solve for a*b*c

add $a3,$a3,$a2 # computing value of f = a + a*b + a*b*c
li $v0,4 #loading syscal print_string to $v0
la $a0,message1 #loading string from message1 into $a0
syscall

li $v0,1 #loading syscal to print_int to $v0
addi $a0,$a3,0 #loading value of f into $a0 by adding f and 0
syscall

li $v0,4 #loading syscal print_string to $v0
la $a0,message2 #loading string from message1 into $a0
syscall
li $v0,35 #loading syscal to print_int to $v0
addi $a0,$a3,0 #loading value of f into $a0 by adding f and 0
syscall

la $t1,val_f #loading address of val_f into $t1
sw $a3,0($t1) #store the computed value in val_f

jal my_max #find the max

la $t1,val_max #loading address of val_max into $t1
sw $a2,0($t1) #store the computed max value in val_max

li $v0,4 #loading syscal print_string to $v0
la $a0,message3 #loading string from message3 into $a0
syscall

li $v0,1 #loading syscal to print_int to $v0
addi $a0,$a2,0 #loading value of max into $a0 by adding max and 0
syscall

move $a0,$a3 #$a0 has the value if f
move $a1,$a2 #$a1 has the value if max

jal my_div

li $v0,4 #loading syscal print_string to $v0
la $a0,message4 #loading string from message4 into $a0
syscall

li $v0,1 #loading syscal to print_int to $v0
addi $a0,$a2,0 #loading value after division into $a0
syscall

li $v0,4 #loading syscal print_string to $v0
la $a0,message5 #loading string from message5 into $a0
syscall

li $v0,1 #loading syscal to print_int to $v0
addi $a0,$a3,0 #loading remainder after division into $a0
syscall

la $t1,val_max #loading address of val_max into $t1
lw $t1,0($t1) #load the stored max value from val_max

li $v0,4 #loading syscal print_string to $v0
la $a0,message6 #loading string from message6 into $a0
syscall

li $v0,1 #loading syscal to print_int to $v0
addi $a0,$t1,0 #loading max value into $a0
syscall

li $v0,4 #loading syscal print_string to $v0
la $a0,message7 #loading string from message7 into $a0
syscall

li $v0, 10 # load syscall exit (10) into $v0.
syscall

my_mul: #input in $a0,$a1 and output in $a2 = $a1*$a0
addi $a2,$0,0 #loading 0 into $a2
again:beq $a0,$0,end #loop - branch to end if value in $a0 = 0
add $a2,$a2,$a1 #adding $a1 to $a2 over and over until end of loop   
subi $a0,$a0,1 #counter for $a0
b again #other wise branch back to again
end:jr $ra #jump to statemnt whos address is $ra in this case its back to line with "jal my_mul"

my_max: #output the max value of val_1,val_2,val_3 in $a2
la $t1,val_1 #loading address of val_1 into $t1
lw $t0,0($t1) #load the value of val_1 in $t0
la $t1,val_2 #loading address of val_2 into $t1
lw $a2,0($t1) #load the value of val_2 in $a2
bgt $a2,$t0,next #check if the val_2 is greater than val_1, if yes jump to next else update $a2
move $a2,$t0
next:
la $t1,val_3 #loading address of val_3 into $t1
lw $t0,0($t1) #load the value of val_3 in $t0
bgt $a2,$t0,end1 #check if the $a2 is greater than val_3, if yes jump to next else update $a2
move $a2,$t0
end1:jr $ra #jump to statemnt whos address is $ra in this case its back to line with "jal my_max"

my_div: #input in $a0,$a1 and quotient in $a2 and remainder in $a3

li $a2,0 #load $a2 with 0
again1:
bgt $a1,$a0,end2 #end of division if $a0 <$a1
addi $a2,$a2,1 #increment $a2 if $a0>$a1
sub $a0,$a0,$a1 #decrement $a0 by $a1
b again1 #repeat the process

end2:
move $a3,$a0
jr $ra #jump to statemnt whos address is $ra in this case its back to line with "jal my_div"