I started with masm32 and i have some questions
I read this
Under Win16, there are two types of calling convention, C and PASCAL
C calling convention passes parameters from right to left, that is , the rightmost parameter is pushed first. The caller is responsible for balancing the stack frame after the call. For example, in order to call a function named foo(int first_param, int second_param, int third_param) in C calling convention the asm codes will look like this:
push [third_param] ; Push the third parameter
push [second_param] ; Followed by the second
push [first_param] ; And the first
add sp, 12 ; The caller balances the stack frame
I also read that in Pascal Convention the called func responsible for stack and in C the caller is responsible..
Can anybody explain how this works??
Coz I dont see any need in balancing stack
first we push 3 params then calling the func
now i guess sp goes 2 bytes up and than the functions pops the three params to use em..
Then sp goes 8 bytes down to the return address and returns no>????
this is how i imagine api funcs work
mov ax,2 mov bx,4 push ax push bx call func ret func proc add sp,2 pop cx pop dx sub sp,6 ;balancing stack .... so why it says caller should balance?? ret func endp
so why balance stack if its all goes nice??
anybody please explain how win32 func call work..