This writing is to demonstrate how to pass many values to a function. As the nature of stack, the last data come in will be the first data coming out. Therefore, the pushing data will be based on this order, as demonstrated in the following codes.
#include <stdio.h>
int foo(int a, int b) {
return (a-b);
}
int main() {
int y;
asm(“movl $10, %eax”);
asm(“push %eax”);
asm(“movl $7, %eax”);
asm(“push %eax”);
asm(“call _foo” : “=r” (y));
//printf(“%d\n”, y);
//getchar();
return 0;
}
Advertisement