2

I saw this question and I would like to know how can we dereference the pointer to int?
This is the code:

int load(int *ptr) 
{
    return *ptr;
}

Now, I know that $a0 contains the pointer. So that's the address of an integer, which we need to return.

Community
  • 1
  • 1
Chris
  • 3,619
  • 8
  • 44
  • 64

1 Answers1

5

In MIPS, you dereference a pointer contained in register $a0 like this:

LW $v0, 0($a0)
JR $ra
markgz
  • 6,054
  • 1
  • 19
  • 41