Question: Write a function that adds the three numbers in $a 0 , $a 1 , $a 2 and prints something like: 2 + 7 +

Write a function that adds the three numbers in $a0, $a1, $a2 and prints something like: 2+7+4=13
assuming that 2,7, and 4 were the values in a0 to a2.
Your function should do the following:
compute the sum of a0, a1, a2 and store it in t0
Print the value in a0
Print a +
Print the number in a1
Print a +
Print the value in a2
Print an =
Print the sum of the numbers that you put in t0.
Print a linebreak
Sample Output
1+2+3=6
2+3+4=9
3+4+5=12
4+5+6=15
5+6+7=18
. data
plus : . asciiz "+"
equal : . asciiz "="
linebreak : . asciiz "\ n "
. text
li $s0,0
li $s7,5
loopstart :
beq $s0, $s7, loopend
addi $s0, $s0,1
addi $s1, $s0,1
addi $s2, $s1,1
move $a0, $s0 # function args go in a0 to a3
move $a1, $s1
move $a2, $s2
jal printFun # then call our function
j loopstart
loopend :
li $v0,10
syscall
printFun :
# your code goes down here ...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To write a function that performs the specified operations we need to implement this using the MIPS ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!