calling assembly functions from c

后端 未结 4 2134
不思量自难忘°
不思量自难忘° 2021-02-02 09:47

I\'m trying to use a function in assembly, invoked from a C project. This function is supposed to call a libc function let\'s say printf(), but I keep getting a se

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 10:15

    One of the best ways to get started with assembly language functions is to write a similar function in C, and then build it with the compiler switch that generates an assembly listing (-S on gcc). Then you can study the output of what the compiler did, and modify as needed.

    This is particularly useful if you're calling functions such as printf which use a different calling convention (because of the variable number of arguments). Calling those functions may be quite different from calling non-varargs functions.

提交回复
热议问题