Interfacing Subroutines with Parameter Passing
Let's now write a C program which calls the assembly program for parameter passing. Let's extend the previous two programs such that if on function call 0 is passed then cursor is turned off and if 1 is passed then cursor is turned on. Calling C program for such may look like:
# include < stdio.h
voidcursw(int);
void main()
{
printf("%s\n", "the cursor is now turning off");
cursw(0); /* call to assembly routine with 0 as parameter
getchar();
printf("%s\n","the cursor is now turning on");
cursw(l); /* call to assembly routine with parameter as1.
}
The variables in C or C + + are passed on the stack.