c - assembly - 来自堆栈的编号

标签 c assembly att x87

这是我的部分代码:

.data

.text
.global fx
fx:
    pushl %ebp
    movl %esp,%ebp

    finit
    fldl 8(%ebp)

我从 C 调用这个函数。因为 8 字节应该有我调用的值,对吗?但是我在 gdb 中看到的是:

(gdb) info float
=>R7: Valid   0x3bf2bd04000000000000 +1.00272590169167575e-312  
  R6: Empty   0x00000000000000000000
  R5: Empty   0x00000000000000000000
  R4: Empty   0x00000000000000000000
  R3: Empty   0x00000000000000000000
  R2: Empty   0x00000000000000000000
  R1: Empty   0x00000000000000000000
  R0: Empty   0x00000000000000000000

Status Word:         0x3802      DE                                    
                       TOP: 7
Control Word:        0x037f   IM DM ZM OM UM PM
                       PC: Extended Precision (64-bits)
                       RC: Round to nearest
Tag Word:            0x3fff
Instruction Pointer: 0x00:0x0804849b
Operand Pointer:     0x00:0xffffcbb0
Opcode:              0xdd45

这是在 fldl 8(%ebp) 之后。我的 friend 制作了相同的程序并且有效。我做错了什么?

在我完整的 C 函数下面:

#include <stdio.h>
float fx(float x);
float gx(float x);

int main(){

float x;
printf("Podaj wartosc x: ");
scanf("%f",&x);
float wynik1 = fx(x);
float wynik2 = gx(x);

printf("\nWynik funkcji f(x)=%f\nWynik funkcji g(x)=%f\n",wynik1,wynik2);
return 0;
}

最佳答案

您加载的是 double (fldl) 而不是浮点 (flds)。

关于c - assembly - 来自堆栈的编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30446565/

相关文章:

c - 文件定义错误

c - 在 C 中读取文本文件时,如何阻止 Windows C 库将 "\r\n"转换为 "\n"?

linux - 汇编:如何将数字转换为ascii并写入显示缓冲区

assembly - 将 2 个两位数相加,结果为汇编中的 3 位数字

c - 汇编:没有这样的386指令

linux - 汇编中的泰勒级数指数函数

assembly - mov 0,%eax上具有x86组件的Segfault

c++ - 能不能动态创建一个进程,维护一个进程池呢?

c - 如何编译 APR 测试脚本

python - 调试器和 cpu 仿真器不检测自修改代码