Find an Online Tutor Now

Mimi R.

asked • 10/21/20

MIPS assembly language

Consider the function with header: int foo(int s, int n, int a, int b).

Write MIPS assembly code for the following statement located inside the above function:


I was told the answer is

add $v0, $a0, $a1

jr $ra

but I don’t understand why... I know

add $v0, $a0, $a1 means

  1. Register $a0 stores the first argument i.e., a0= s
  2. & Register $a1 stores the second argument i.e, a1=n
  3. add instruction adds the values in $a0 and $a1 and saves the result in register $v0.
  4. The value stored in register $v0 is the one to be returned from the function.

but what about the

jr $ra

1 Expert Answer


Michael S. answered • 10/23/20

5 (3)

Friendly Cyber Warfare Veteran With Many Technology Skills

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.