How to use C libraries in assembler?

I want to know how to write a text editor in assembler. But modern operating systems require C libraries, especially for their window systems. I found this page that helped me a lot.

But I am wondering if there are any details that I should know. I know enough assembler to write programs that will use Windows on Linux using GTK +, but I want to understand that I have to send functions so that it is a valid input, so it will be easier to use all the C libraries. For interaction between assembler C and x86, I know what you can learn from this page and a little more.

+4
source share
3 answers

One of the most instructive ways to learn how to call C from assembler is:

  • Write a program C calling the function of interest C
  • Compile it and see the list of assemblies ( gcc -S )

This approach makes it easy to experiment, starting with what is already known. You can change the source of C and see how the generated code changes, and you can start with the generated code and change it yourself.

+8
source
  • push parameter on the stack
  • function call
  • clear stack

The links you have in your question show all of these steps.

+2
source

The OS can determine the call standard (it should pretty well determine the standard for calling system calls), in which case you only need to find where the documents are and read it carefully.

+2
source

All Articles