1

I need to develop a procedure for Assembly language and call that procedure from C language (pass a string and return an integer value). My assembly procedure works fine "stand-alone". I need help with connecting them together.

Program is supposed to run on Intel 8086. I need to use MASM or emu8086 as assembler/simulator. Kindly recommend a C compiler and also a way to make the simple C program that is able to call the assembly procedure and get the returned value.

How can I pass a string to this external function?
How can I connect the ASM file and the C file? (How will the compiler know where is the definition/code for this procedure?)
How can I get the string sent from C in Assembly language, also how to return the integer to C?

1
  • Since you didn't upvote or even comment, I deleted my answer. Commented Jan 11, 2013 at 21:20

1 Answer 1

2

recommend a C compiler

Not enough info, however if your platform is significant enough, chances are that GCC already supports it.

and also a way to make the simple C program that is able to call the assembly procedure and get the returned value.

The way for writing simple C programs is using a text editor. (Oh wait, you're interested in the code? Here it goes:

#include <stdio.h> extern int foo(); int main() { int i = foo(); printf("%d\n", i); return 0; } 
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the prompt reply. Yes this is exactly what i need. Just a few clarifications/suggestions. Sorry for not providing sufficient information in the first place. How can i pass a string to this external function? How can i connect the ASM file and the C file? (How will the compiler know where is the definition/code for this procedure?) How can i get the string sent from C in Assembly language, also how to return the integer to C? THANK YOU SO MUCH!
@user1969973 You read a C tutorial before asking? foo("HelloWorld");

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.