Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different between jump and jump and link

Tags:

mips

Could someone provide an example of the usefulness of the jal instruction can how it can be used to return to the main body after completing a subroutine?

regards

like image 588
maxflow Avatar asked Mar 30 '12 03:03

maxflow


People also ask

What is the difference between jump and jump and link?

Jump and Link instructions are similar to the jump instructions, except that they store the address of the next instruction (the one immediately after the jump) in the return address ($ra; $31) register. This allows a subroutine to return to the main body routine after completion.

What is the difference between jump vs jump and link instruction in MIPS?

The difference is that the target address for JR comes from a register specified in the instruction. The jump-and-link instruction ( JAL ) behaves like the simple jump instruction ( J ), but also stores a return address in register 31 ($ra).

What is difference between jump and Call return?

JUMP or GOTO is a transfer of the control to another location and the control does not automatically return to the point from where it is called. On the other hand, a CALL or procedure/function call returns to the point from where it is called.


1 Answers

"jmp" is a "goto".

"jal" is a "gosub"

jal saves the return address in $ra, should you wish to return from whence you came ;)

http://logos.cs.uic.edu/366/notes/mips%20quick%20tutorial.htm

like image 138
paulsm4 Avatar answered Sep 22 '22 23:09

paulsm4