Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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 ...
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions