Rez February 2016

What's the proper way to update a value passed in assembly?

I'm using the SPARC architecture. I have to update the number of a long passed as an argument without returning it, but I don't know how to do that because the input registers are used for both the parameters and for returning a value. I've seen from using instructions such as

add   %l0, %l1, %i1

that it's possible to modify the contents of an i register, but as far as I can tell that changes the "copy" of the parameter rather than the parameter itself. I've experimented with the load command and store command in ways such as

ld    [%o1], %i1

and

st    %l1, [%fp-8]

and they don't seem to change what I need to be changed.

Answers


Rez February 2016

I figured it out. The save instruction makes the argument available in an in register (in my case, %i1), and from there it's just

st %l1, [%i1 + 1]

and I have to make sure the number in place of 4 is compatible with the number of bytes between the elements of the array. So in this case +1 works for a char array.

Post Status

Asked in February 2016
Viewed 1,902 times
Voted 9
Answered 1 times

Search




Leave an answer