MIPS Assembly It is desired to call a function fib0 that is

MIPS Assembly

It is desired to call a function fib0 that is located \"somewhere\" in segment B (address Bxxxxxax) from an address in segment A (Axxxxxxx). Write code snippets (before calling fib, and if needed inside fib), that use any valid MIPS instructions to implement this. You can install \"helper\" instructions anywhere in the code segments.

Solution

#Saving $ra in stack so that the address to come back to is known after function is called

addi $sp, $sp,-4

sw $ra, 0($sp)

#Calling the method

jal fib;

#Restoring the address from the stack register

lw $ra, 0($sp)

addi $sp, $sp,4

1) A stack is an area of memory that grows and shrinks dynamically

2) In MIPS, the stack grows downwards which is not the case in other programming languages.

MIPS Assembly It is desired to call a function fib0 that is located \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site