...but in inline assembly you can access the heap variable as well as the stack ones. However when mixing pure assembler with C modules it gets a little more difficult than that.
Code:
extern "C" DWORD Add32(DWORD dwVal1,DWORD dwVal2);
int main(void)
{
DWORD dwValue=Add(300,10000);
return(0);
}
TASM
Code:
.386
...
...
public Add32
_Add32 proc
ARG: DWORD dwVal1,DWORD dwVal2
push ebp
mov ebp,esp
mov eax,dwVal1
add eax,dwVal2
pop ebp
ret
_Add32 endp
Now this code should work correctly since everything is passed via the stack to Add32. But if you wanted to be able to access a global DWORD in C from assembly you would have to declare the variable in asm as well and specify that it was defined externally to the asm module. In C you would simply declare it as normal.
It's absolutely ridiculous to even try this because I cannot fathom why you would want to alter a global C variable inside of a pure assembly module. But the same thing also holds true for structs. You pass the address or retrieve the address. Retrieving it requires that the struct be declared somewhere in the asm source, otherwise the asm module has no way of knowing what the struct is. As well the data alignment of the 2 structs (the C struct and the asm struct) must be identical or serious memory problems will occur.
Best bet is to pass a pointer to any asm function via the stack and access the variable via offsets from ebp and create locals relative to esp or in memory. I recommend using the stack. And there are ways to poke around the code segment and change what CS:EIP points to but since that is not in the realm of well-behaved code I will not explain it.