How to create a C-callable function in assembly

286 Views Asked by At

I am learning assembly using Jeff Duntemann's book. I am trying to figure out how to write function that can be called in C.

Say for example that I want to implement the following function in assembly:

int my_function(int a, int b)
{
      return a+2*b
}

How do I write that? How do I access the arguments and how do I tell C that the return value is an integer?

EDIT: I am doing this on an old 32bit ubuntu.

0

There are 0 best solutions below