函数的使用与子程序的用法相同,没有什么特殊之处。例如
.............................................................................
int
max(int
a,
int
b)
{
/*
返回a和b的最大值
*/
return
(a
>
b)
?
a
:
b
}
.............................................................................
int
a
=
5,b
=
8,c
=
3
printf("a,b,c中的最大值是
:
%d\n",max(max(a,b),c)
你是指内联汇编吧?比如下面这个例子:
#include <stdio.h>int func(int a, int b)
{
return a - b
}
int main()
{
//计算 12-5
int a = 12, b = 5 //给定两个数
int res //用来记录结果
__asm{ //内联汇编
push b //b压栈
push a //a压栈,注意C中函数接受参数的时候入栈是反着的
call func //调用函数func, 返回值保存在eax里
mov res, eax //将eax里的值赋给res
}
printf("%d\n", res) //输出结果,得到7
return 0
}