Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Translate function f into MIPS assembly language. If you need to use registers $t0 through $t7, use the lower numbered registers first. Assume the function

Translate function f into MIPS assembly language. If you need to use registers $t0 through $t7, use the lower numbered registers first. Assume the function

declaration for func is "int func(int a, int b);" .

The code for function f is as follows:

int f(int a, int b, int c, int d){

return func(func(a, b), c + d);

}

Answer:

f: addi $sp,$sp, -12

sw $ra,8($sp)

sw $s1,4($sp)

sw $s0,0($sp)

move $s1,$a2

move $s0,$a3

jal func

move $a0,$v0

add $a1,$s0,$s1

jal func

lw $ra,8($sp)

lw $s1,4($sp)

lw $s0,0($sp)

addi $sp,$sp,12

jr $ra

Can someone please explain why we only defined 3 variblaes and ignorerege int d and why we sayed jal func and then move $a0, $v0, and are we assuming $a0 and $a1 are and b respectivly too?(it would be great if you could explain each process and its reasoning). Thank you so much!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

What lessons in intervention design, does this case represent?

Answered: 1 week ago