相关疑难解决方法(0)

Why does Windows64 use a different calling convention from all other OSes on x86-64?

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 …

windows x86-64 calling-convention

97
推荐指数
4
解决办法
2万
查看次数

汇编代码的长度可以指示执行速度吗?

我正在学习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)

c assembly clang

1
推荐指数
1
解决办法
185
查看次数

标签 统计

assembly ×1

c ×1

calling-convention ×1

clang ×1

windows ×1

x86-64 ×1