Why does C not push a pointer on the stack when calling a assembly function?

前端 未结 2 903
长发绾君心
长发绾君心 2021-01-20 22:42

I am currently trying to get some experience with calling assembly functions from C. Therefore, I created a little program which calculates the sum of all array elements.

<
2条回答
  •  心在旅途
    2021-01-20 23:41

    The calling convention the C compiler will use depends on your system, metadata you pass to the compiler and flags. It sounds like your compiler is using the System V AMD64 calling convention detailed here: https://en.m.wikipedia.org/wiki/X86_calling_conventions (implying that you're using a Unix-like OS on a 64 bit x86 chip). Basically, in this convention most arguments go into registers because it's faster and the 64 bit x86 systems have enough registers to make this work (usually).

提交回复
热议问题