TC is the United States Borland Company on the IBM PC developed an efficient, optimized C compiler program, it has an efficient full screen editing program, in the integrated development environment can support editing, compilation, connection debugging and operation of the process of continuous completion.
TC provides the interface with assembly language and the function of inserting assembly instruction code directly in C program, which supports the invocation of functions written in assembly language in the way of "far call" and "near call".
TC calls assembly language functions, the compilation of assembly language requirements is very strict, and the case of letters also have a strict distinction. If you write an assembly function for a TC call without writing in the prescribed format, the call will not succeed.
Here is an example of calling the assembly function in the TC, and then explaining how to do it in detail.
The following steps are gathered:
1, in the TC integrated environment to write a main program (named TCMAIN.C)
/* Program function: Create an integer array and enter the values of each element of the array, invoke the assembly code to obtain the maximum value of the and the maximum position in the array */
Void Main ()
extern found (int i,int*j,int *k,int *s);
printf ("Enter Values of array:/n");
scanf ("%d", &s[i]);
printf ("/nthe max_value is:%d/n", j);
printf ("The Place is:%d/n", K);
2, write the following assembler code (named Tcfound.asm)
in the TC Integrated environment (function: Get the maximum value of the array element and the position of the maximum in the array)
_text SEGMENT BYTE Public ' CODE '
assume CS: _text
_found PROC NEAR
&NBSP;&N Bsp mov bp,sp
comp: cmp Ax,[si]
bigger: inc si
mov& nbsp DI,[BP+6]
3, with MASM macro assembly at the command line on the TCFOUND.ASM assembly:
Generate a module file after assembly Tcfound.obj
Note: If Tcfound.asm is not in the directory, you must indicate the path to the file.
After the assembly, the tcfound.obj is copied to the TC catalogue to facilitate the establishment of the engineering documents under TC.
4, the establishment of engineering documents
A new file is built in the TC integration environment, which reads:
Only the above two lines of content, after writing to save as Mytc.prj
Note: MYTC. PRJ is an engineering document, and the suffix must be the following. PRJ, this is the identification of engineering documents in TC. This project document
Only two lines of content, indicating that the project contains TCMAIN.C and tcfound.obj two program modules. On engineering documents
Compiling the connection compiles and connects the two files sequentially, and finally connects to the executable file MYTC.EXE
5, before compiling the connection settings
Because the TC is very sensitive to uppercase and lowercase letters, and the obj files generated by the MASM assembly are all uppercase letters, you need to turn off the case-sensitive link (case sensitive connection) switch in the linker option.
The operation is as follows:
F10--option--linker Enter the bottom of the menu to select the most of the "case-sensitive LINK", the cursor stop on this option, enter can change its set to "off" state.
Finally, don't forget to save the results of your settings.
6, compile connection
Select menu F10---project---project name Enter the project file name you just created MYTC
menu F10---Compile---build all After the carriage return starts to compile the connection to the project file Mytc.prj, finally generates the executable file MYTC.EXE