[ebp-4] is where my_func's local copy of m is stored on the stack. [m] is where main's local copy of m is stored. What's missing here is the definition for main's copy of m. I would have expected it to also be an offset from ebp. Using VS2005, I compiled this example, using volatile to prevent optimizing the muliplty away.
__inline int myfun(int a, int b)
{
int m;
m = a*b;
return (m);
}
int main (void)
{
volatile int a, b, m;
a = 1;
b = 2;
m = myfun(a, b);
return(0);
}
and got this assembly code. Note that m and a share the same memory location: -4[ebp+8]:
_b$ = -8 ; size = 4
_m$ = -4 ; size = 4
_a$ = -4 ; size = 4
_main PROC
sub esp, 8
mov DWORD PTR _a$[esp+8], 1
mov DWORD PTR _b$[esp+8], 2
mov ecx, DWORD PTR _b$[esp+8]
mov eax, DWORD PTR _a$[esp+8]
imul eax, ecx
mov DWORD PTR _m$[esp+8], eax
xor eax, eax
add esp, 8
ret 0