C and Asm
Posted: Fri Sep 06, 2002 4:57 am
Hi,
I just have a question about mixing asm and C.
If I have an ASM function that takes three args say a WORD, BYTE and DWORD, C prototype like this
SomeFunc( WORD, BYTE, DWORD );
If I call it from C like this
SomeFunc( 32546, 200, 20059958 );
I know that C passes these args from right to left.
If I have a 32Bit stack would I access the args like this
push ebp
mov ebp, esp
mov eax, word [ebp + 4] ; the word arg
mov ebx, byte [ebp + 6] ; the byte arg
mov ecx, dword [ebp + 7] ; the dword arg
.....
pop ebp
ret
I guess what I am asking is that if a stack has 32Bit pushes/pops by default, will a WORD on the stack still only be 2 bytes or will it be padded to 4 bytes?
thanks.
I just have a question about mixing asm and C.
If I have an ASM function that takes three args say a WORD, BYTE and DWORD, C prototype like this
SomeFunc( WORD, BYTE, DWORD );
If I call it from C like this
SomeFunc( 32546, 200, 20059958 );
I know that C passes these args from right to left.
If I have a 32Bit stack would I access the args like this
push ebp
mov ebp, esp
mov eax, word [ebp + 4] ; the word arg
mov ebx, byte [ebp + 6] ; the byte arg
mov ecx, dword [ebp + 7] ; the dword arg
.....
pop ebp
ret
I guess what I am asking is that if a stack has 32Bit pushes/pops by default, will a WORD on the stack still only be 2 bytes or will it be padded to 4 bytes?
thanks.