
Michael S. answered 10/23/20
USMC Cyber Warfare Vet, OSCP/OSCE Prep, Dev / Web Dev, DFIR, AI/ML
The jr (Jump Register) instruction causes the PC to jump to the contents of the first source register, in this case - $ra, which holds the return address of the location following where we jumped to the foo function. This has to be placed into ra so that the program knows where to return to after executing the foo function.
Also of note, the v0 register contains the returned value of a subroutine; if the value is 1 word in size only $v0 is significant, otherwise $v1 is as well.