Interacting with C program (8086 + C)

Thread Starter


Joined Jun 19, 2007
i have able to write c program interact with 8086 program. For that, i simply call the assembly language program in C coding. But I am not able to pass the parameter to the assembly langugae programming. I tried with PUBLIC and EXTERN Directives in ALP coding. can any one guide me with sample coding. i used MASM5.0 and TC software.


Joined Nov 26, 2007
It sounds to me like you need to write an assembly procedure (PROC) to go with the part of your application written in C. My experience in mixed-language programming was about 15 years ago. Hopefully my example will be helpful.

The C portion of your app will have a call in it to what the C portion thinks is just another C function. In reality the called function will be an assembly PROC. I'm assuming the call looks like this:

result = my_function(value);

and that the prototype of this function is like so:

short my_function(short);

The assembly proc looks like this:

.MODEL small
PUBLIC _my_function
_my_function PROC NEAR
push bp
mov bp, sp ; Save BP and copy stack pointer to BP
push si ; save affected register
mov si, Value

; do what needs to be done
; put value to be returned in AX

pop si ; clean up registers used
pop bp ; restore BP to its former value
_my_function ENDP


Joined Aug 15, 2007
Are you using MASM to create an .OBJ file to be linked in your project, or are you shelling out (using some form of exec() ) to have the ASM program (.COM or .EXE) run? And, if you are exec'ing, which OS are you using?

My favorite 80x86 assembler was A86, which I believe is still available on the 'Net. It does 80x86 assembly without all the overhead of MASM. There are also files explaining how to interface to a C program in either of the two cases above.



Joined Nov 26, 2007
The code I posted came from a book on DOS programming using C and assembler (of which I am a co-author). The work I did was in 1991, and I used Borland's Turbo C toolset. IIRC, I was using Windows 3.1 at the time.

I would use the compiler to compile the C portion into an .obj file, use the assembler to assemble the .asm code, and use the linker to combine the .obj files.

The Turbo assembler (TASM) seemed a lot easier to use than MASM, and the Borland debugger seemed to me to be superior to the MS debugger of the time. The debugger's UI was nicely laid out, so I could find out what was going on anywhere in memory, in the registers, and could single-step through the code, watching what was happening.

I seem to remember having A86, and I might still have it on a 5 1/4 " floppy somewhere, but I don't recall doing much with it.


Joined Aug 15, 2007
Another idea for Ramesh:
Turbo C can generate just the assembler output, although you may need to use the command-line version (TCC??). If you compile the following to assembler, you can see what is going on:

Rich (BB code):
int dummy(int parm);

int main (int argc, unsigned char * argv[])
  int a;
  unsigned char c;
  int d;

    a = argc;
    c = *argv[0];

    d = dummy(a);

int dummy(int parm)
    return (parm);
Turn off all optimization, so TC does not remove any of your code. After this, you can replace the call to dummy() with an exec{) call to see how that is handled.