How can I call an assembly file that contains a simple function from a C program function?

I want to write a simple C program example that calls a file in .asm format and executes his code.
PSEUDO-CODE ;)

    call(functionwithasmcode.asm);

Upvotes: 0

Views: 225

Answers (1)

0___________
0___________

Reputation: 68033

Yes, you can::

call("functionwithasmcode.asm");

This function will have to:

  1. Invoke the assembler and linker - create the dynamic link library.
  2. Depending on the system you need to load this library (for example in Linux by calling the dlopen function, in Windows LoadLibrary).
  3. Find your function in the library, assign to function pointer (it is also OS dependant for example in Linux dlsym, windows GetProcAddress)
  4. call the function using the function pointer from the point 3.

Upvotes: 1

Related Questions