Convert C to MIPS assembly with pointers

I am trying to keep a pointer initialized as:

int* x;

      

into a regular variable initialized as

int y;

      

in the following way:

y = *x;

      

In mips it is as easy as

$s1 = ($a0);?

      

And vice versa?

+3


source to share


1 answer


Assembly language usually has no operators. You probably need an instruction lw

:

lw $s1, 0($a0)

      



Usage $s1

and of $a0

course depends on context. If this register matches the rest of the code you are using, you should be fine.

+3


source







All Articles