简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM