Adding more than four params in Assembly

Viewed 171

I have C++ file and .asm file as shown below.Am trying to add all params i passed in summation function

summation(int a ,int b ,int c ,int d, int e,int f)

c++ file looks like this :

#include <iostream>
#include <conio.h>
#include<stdlib.h>

using namespace std;

extern "C" int summation(int a ,int b ,int c ,int d, int e,int f);


int main(){

cout << "Summation : "<<summation(1,2,7,1,8,10)<<endl;
return 0;
}

And asm file looks like this :

.code

summation proc

    sub rsp,30h
    mov eax,ecx
    add eax,edx
    add eax,r8d
    add eax,r9d

    add eax,dword ptr [rsp+20h]
    add eax,dword ptr [rsp+28h]
    add rsp,30h
    ret 
summation endp

end

Having those code the result is always 22 (It should be 29). What's wrong with my code ?

3 Answers
Related