views:

816

answers:

1

I think I know how to handle this case, but I just want to make sure I have it right. Say you have the following C code:

int myInt = 3;
int* myPointer = &myInt;
int** mySecondPointer = &myPointer;

P contains an address that points to a place in memory which has another address. I'd like to modify the second address. So the MIPS code:

la $t0, my_new_address
lw $t1, ($a0) # address that points to the address we want to modify
sw $t0, ($t1) # load address into memory pointed to by $t1

Is that the way you would do it?

+2  A: 

Yes, that's correct as far as I can tell. It would have been easier if you used the same variable names (e.g. symbols instead of hard register names).

Why haven't you simply compiled the c-code and took a look at the list-file or assembly-output? I always do that when in doubt.

Nils Pipenbrinck