Hello!
I've got a problem in understanding how function parameters on the stack work. Let's say I have a C function that's called "generate" and I want to translate it to Assembly;
How would I access the structure members and the function parameters? I know that you access the function parameters through ESP, but after ESP there's a number which I'm not sure of (I've seen different codes and some start at 4, some start at 8 and some start at 16 :eek). Could anyone explain?
I've got a problem in understanding how function parameters on the stack work. Let's say I have a C function that's called "generate" and I want to translate it to Assembly;
typedef struct {
int foo;
unsigned char *bar;
} generate_struct;
int generate(generate_struct *g, int x, int y, long *res);
How would I access the structure members and the function parameters? I know that you access the function parameters through ESP, but after ESP there's a number which I'm not sure of (I've seen different codes and some start at 4, some start at 8 and some start at 16 :eek). Could anyone explain?
MOV EAX, ; EAX now points to "generate_struct *g"?
; Would I now access the structure members through EAX like below?
MOV foo, ; an "int" is 4 bytes long
MOV bar, ; a pointer is 4 bytes long (?)
Every 'modern' assembler allows you to refer the variables by their names.
I would recommend you read http://win32asmcommunity.net/phpwiki/index.php?pagename=TheStack