home *** CD-ROM | disk | FTP | other *** search
- Program CCallsPascal;
- { This is a sample Pascal program that demonstrates a way of }
- { interfacing a Turbo Pascal procedure to be called from the }
- { Turbo C module that is linked in. }
- {$A-,F-}
-
- Uses Crt;
-
- Var
- Count : Integer; { Counter var for # of calls to proc }
- _rsp : Pointer; { Pointer to memory to save SI & DI }
- SiDiStack : Array[0..10] of Word;
- { Memory locations for SI and DI }
-
- {$L list4-6}
-
- Procedure StartUpC; External;
-
- Procedure PasProc;
- { This is the procedure that will be called from within the }
- { Turbo C object module. All this will do is output a string }
- { to the screen and increment a global variable. This }
- { variable will keep track of the number of times the routine }
- { is called. }
-
- Begin
- Inc( Count ); { Add 1 to global variable }
- Write( Count, ' ' ); { Ouput the new value }
- End;
-
- Begin
- Count := 0; { Initialize the counter. }
- _rsp := @SiDiStack; { Initialize memory to save SI & DI }
- ClrScr; { Clear the user screen }
- StartUpC; { Call the external C routine }
- Writeln; { Output a CR/LF to screen }
- Writeln( 'The Pascal routine was called a total of ',
- Count, ' times.' );
- { Report number of times called }
- Write( 'Press any key to continue...' );
- While( Not Keypressed ) Do
- { NOP }; { Pause the program for keypress }
- End.