I am writing a simple graphics program in an assembly for training purposes; for this I intended to use OpenGL or SDL. I am trying to call the OpenGL / SDL function from an assembly.
The problem is that unlike many of the OpenGL / SDL build and tutorials I found on the Internet, OpenGL / SDL on my machine does not seem to use the C calling convention. I wrote a simple C program, compiled it to the assembly (using the -S switch) and, apparently, the assembly code that is generated by GCC calls the OpenGL / SDL functions, passing parameters in registers instead of pushing them onto the stack.
Now, the question is how to determine how to pass arguments to these OpenGL / SDL functions? That is, how can I determine which argument matches which registers?
Obviously, since GCC can compile C code to call OpenGL / SDL, there must therefore be a way to determine the correspondence between function arguments and registers. In C-calling conventions, the rule is easy, push the parameters back and return the value to eax / rax, I can just read their C documentation, and I can easily understand how to pass the parameters. But what about these?
Is there a way to invoke OpenGL / SDL using a C call convention?
btw, I use yasm, with gcc / ld as the linker on Gentoo Linux amd64.
source
share