AMD has an ABI specification that describes the calling convention to use on x86-64. All OSes follow it, except for Windows which has it's own x86-64 calling convention. Why?
Does anyone know the technical, historical, or political reasons for this difference, or is it purely a matter of NIHsyndrome?
I understand that different OSes may have different needs for higher level things, but that doesn't explain why for example the register parameter passing order on Windows is rcx - rdx …
我正在学习C,请考虑以下代码片段:
#include <stdio.h>
int main(void) {
int fahr;
float calc;
for (fahr = 300; fahr >= 0; fahr = fahr - 20) {
calc = (5.0 / 9.0) * (fahr - 32);
printf("%3d %6.1f\n", fahr, calc);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是将Celsius到华氏温度转换表从300打印到0.我用以下代码编译:
$ clang -std=c11 -Wall -g -O3 -march=native main.c -o main
Run Code Online (Sandbox Code Playgroud)
我还使用此命令生成汇编代码:
$ clang -std=c11 -Wall -S -masm=intel -O3 -march=native main.c -o main
Run Code Online (Sandbox Code Playgroud)
哪个生成1.26kb文件和71行.
我稍微编辑了代码并将逻辑移到另一个函数中,该函数在main()中被初始化:
#include <stdio.h>
void foo(void) {
int fahr;
float calc;
for (fahr = 300; fahr >= …Run Code Online (Sandbox Code Playgroud)