汇编和C相互调用

这里有几个原则:
1.调用者需要在调用前声明被调用者。
c的做法
void myprint(char* msg, int len);

int choose(int a, int b)
{
	if(a >= b){
		myprint("the 1st one\n", 13);
	}
	else{
		myprint("the 2nd one\n", 13);
	}

	return 0;
}

汇编的做法:
extern choose
...
...
push	num2nd
push	num1st
call	choose

2.汇编提供给外部C调用的代码需要在汇编中做全局声明
global myprint

3.调用者需要负责清除堆栈
push	num2nd
push	num1st
call	choose
add	esp, 4

你可能感兴趣的:(汇编)