Friday, March 2, 2018

Stack Function Call in C

A very simple program in C language to show how to call a function using stack.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.




Program Listing

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>

unsigned int far *ptr ;
void ( *p )( void ) ;

void f1( ) ;
void f2( ) ;

void main( )
{
f1( ) ;
f2( ) ;

printf ( "\nback to main..." ) ;
exit ( 1 ) ;
}

void f1( )
{
ptr = ( unsigned int far * ) MK_FP ( _SS, _SP + 2 ) ;
printf ( "\n%d", *ptr ) ;

p = ( void ( * )( ) ) MK_FP ( _CS, *ptr ) ;
( *p )( ) ;
printf ( "\nI am f1( ) function " ) ;
}

void f2( )
{
printf ( "\nI am f2( ) function" ) ;
}




No comments:

Post a Comment