先说结论:
- 汇编中函数调用前要传递的参数从右到左依次设置
- 函数从左到右的整型或指针参数依次用 edi, esi, edx, ecx, r8d, r9d, 堆栈保存,最多6个整型参数可以通过寄存器传递
- 函数从左到右的浮点参数依次用xmm0, xmm1, xmm2, …, 保存
- 混合类型参数分类型分别按2,3规则传递
- 函数返回值整型用rax或eax传递,浮点类型用xmm0传递
原始代码
#include<iostream>
#include<string>
int ifunc4(int a, int b, int c, int d){
return a+b+c+d;
}
int ifunc5(int a, int b, int c, int d, int e){
return a+b+c+d+e;
}
int ifunc6(int a, int b, int c, int d, int e, int f){
return a+b+c+d+e+f;
}
int ifunc7(int a, int b, int c, int d, int e, int f, int g){
return a+b+c+d+e+f+g;
}
float ffunc4(float a, float b, float c, float d){
return a+b+c+d;
}
float ffunc5(float a, float b, float c, float d, float e){
return a+b+c+d+e;
}
float ffunc6(float a, float b, float c, float d, float e, float f){
return a+b+c+d+e+f;
}
float ffunc7(float a, float b, float c, float d, float e, float f, float g){
return a+b+c+d+e+f+g;
}
double dfunc4(double a, double b, double c, double d){
return a+b+c+d;
}
double dfunc5(double a, double b, double c, double d, double e){
return a+b+c+d+e;
}
double dfunc6(double a, double b, double c, double d, double e, double f){
return a+b+c+d+e+f;
}
double dfunc7(double a,