Manoj Doubts
Manoj Doubts

Reputation: 14049

How to include the assembly code in my C code in Turbo C?

How to include any assembly code lines into my C program ?

In turbo c is there a possibility to add an assembly code file (.asm) to a project of few .c files?

Upvotes: 0

Views: 4949

Answers (4)

Rishav Ambasta
Rishav Ambasta

Reputation: 1

void func()
{
asm://assembly statements...
asm://assembly statements...
...
}

Upvotes: 0

Ray
Ray

Reputation: 106

You can use your makefile to define actions for different target types. For C types (e.g. foo.c) have the C compiler invoked. For ASM files, invoke the assembler. The output from either should be an object file (e.g. .o) which can all be compiled together by the linker.

If you have a little bit of assembly, go ahead an inline. Otherwise, I recommend separate modules and functional decomposition as the best way to manage everything. Especially if you need to support different targets (i.e. cross platform development).

Upvotes: 1

Toon Krijthe
Toon Krijthe

Reputation: 53366

You can also link in the object files. But inline assembler is much easier to maintain.

Upvotes: 0

xsl
xsl

Reputation: 17416

One way to include assembly code is to add a wrapper function and write the assembly code in the asm block, as shown in the example below:

void wrapper_function()
{
    asm
    {
        /* your assembly code */
    }
}

Upvotes: 2

Related Questions