How to invoke an assembler _c language in TC2.0

Source: Internet
Author: User

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 */
#include <stdio.h>
Void Main ()
    extern found (int i,int*j,int *k,int *s);
    int i,j,k,s[10];
    printf ("Enter Values of array:/n");
    for (i=0;i<10;i++)
       scanf ("%d", &s[i]);
    found (i,&j,&k,s);
    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)
  public _found
_text SEGMENT BYTE Public ' CODE '
  assume CS: _text
_found  PROC NEAR
&NBSP;&N Bsp mov  bp,sp
   mov  cx,[bp+4]
   dec  CX
   mov  si,[bp+10]
   mov  dx,1
   mov  bx,0
comp:  cmp  Ax,[si]
   ja  bigger
   mov  Ax,[si]
   mov  bx,dx
bigger:  inc  si
   inc  SI
   inc  DX
   mov& nbsp DI,[BP+6]
   mov  [di],ax
   mov  di,[bp+8]
   mov  [di],bx
   pop  BP
_found  ENDP
_text  ENDS

3, with MASM macro assembly at the command line on the TCFOUND.ASM assembly:

MASM tcfound.asm
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:
Tcmain. C
Tcfound. Obj
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.