Question

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?

Was it helpful?

Solution

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 */
    }
}

OTHER TIPS

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).

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

void func()
{
asm://assembly statements...
asm://assembly statements...
...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top