I am trying to write the following function in y86 (Assembly)
C code:
void f (long x, long y, long *sum, long *diff) {
*sum = x + y;
}
long a, b;
void main (void)
{
f (7, 10, &a, &b);
halt();
}
Don't give me the answer to how to write this in assembly, I only want the answer to both my question :
Question 1 : How do we pass a reference as a parameter?
Question 2 : How do we return a void value?
Side-notes:
I've looked up this post, but the answer push [edi];
doesn't work for y86.
Normally, in a function with a return value, we use: ret
in order to return what's in the %eax
register, and to remove the return adress in the stack. Now I just want to remove the return address without actually returning a value.
According to this website,
If your function returns void (e.g. no value), the contents of these registers are not used.
Is it possible that the value is returned but we just don't use it, or am I understanding it wrong? I'd like more explanation on this if possible.