问题标签 [x87]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
330 浏览

assembly - 在 x87 FPU 中简单添加单精度浮点数

我正在编写一个小型汇编程序,它采用两个单精度浮点数,将它们相加并显示结果。但是,我希望将结果保存在寄存器中以备后用。为了帮助我开始,我将一个 c++ 程序编译成一个汇编程序,并尝试对其进行编辑。但是,我不明白我得到的结果如下:

s首先,关于浮点数,这意味着 32 位和64 位,我是否正确l?其次,为什么将 32 位浮点值弹出到28(%esp)中,只是为了将其存储回数据寄存器堆栈中?删除这两行会导致结果不太精确,这很奇怪。最后,它再次弹出数据寄存器堆栈,但这次是 64 位值。我想要一个单精度 32 位值。但是,更改ls导致我得到 0。有人知道到底发生了什么吗?

0 投票
1 回答
2000 浏览

c++ - Porting old compiler ftol (float to long) function to C

I'm relying on an old implementation that does some calculations and converts float's to int.

However, after replicating the calculations some values are off due different rounding results.

It boils down that the binary is using the following code for converting a float to int (long).

#xA;

This behaves differently then simply doing unsigned int var = (unsigned int)floatVal;.

I believe this is an old ftol implementation and was done because converting from float to int was very slow and the compiler needed to change the FPU rounding mode.

It looks very similar to this one http://www.libsdl.org/release/SDL-1.2.15/src/stdlib/SDL_stdlib.c

Can anyone assist me in converting the function to C? Or tell me how I can create an inline ASM function with float parameter and return int using Visual Studio. The one in SDL_sdtlib.c has no header and I'm not sure how to call it without function args.

0 投票
0 回答
792 浏览

assembly - 使用 FPU Nasm x86 程序集进行计算时获取 -nan

首先我要感谢任何回复此问题的人,非常感谢您的帮助!

我正在尝试计算作为命令行参数传递给我的程序的一组浮点数的标准偏差。首先,我将每个参数字符串存储在一个temp变量中,然后使用sscanf(). 我的第一个问题是第一个(当我说第一个时,我说的是我的程序名称之后的那个......所以实际上是第二个)命令行参数没有被解析。在我用来计算数字平均值的循环中,我尝试在将每个参数解析为浮点数后立即打印出来。它总是打印除第一个之外的所有内容。第一个总是打印为-nan. 此外,该变量也会std_dev被打印出来-nan,即使我从未修改过它。这让我很困惑。我究竟做错了什么?

这是代码:

再次感谢!

[编辑:我还没有完成实际计算标准偏差。我所拥有的只是计算平均值的循环。]

0 投票
1 回答
676 浏览

assembly - About x87 FPU precision

In the Intel IA-32 software developer manual. It says that bit 8 & 9 of x87 FPU control word determines the precision of floating-point calculations. The default precision is double extended precision. After the instruction "FINIT" is executed, the precision is set to double-floating. The problem is that, after "FINIT" is executed, x87 FPU use only 64 bit of the 80-bit data registers to calculate. And the FPU can't accept(output) double-extended precision floating value from(to) memory. Is this right?

0 投票
1 回答
1030 浏览

assembly - 如果上面的工作,汇编程序如何跳转

我们正在比较两个值 1pi

然后我使用“如果高于则跳转”或如果更大则跳转:

我们有:

所以我们不跳。

它只发生在条件:

x - value > 0是真的,对吧?溢出标志在 jg 中是如何工作的?

我们跳吗?

使用 FPU

0 投票
0 回答
617 浏览

assembly - 汇编器 taylor 系列 arctg x

我在汇编中编写了程序,它只从C程序中获取两个变量,然后在最后将答案返回给C程序。我在查找汇编文件中有什么问题时遇到了问题。

我的目标是使用 FPU (nasm) 编写程序,该程序将计数arctg (x),其中x是一个变量C,由用户输入。第二个变量是准确性,即泰勒级数整数的数量。

程序 C

程序assembler

当我键入 accuracy > 2 (dokladnosc)程序停止时,当我键入1程序返回时-x,不是x

我在 nasm 中使用这些行进行编译:(我正在使用 gcc)

我尝试将 ST0 发送到 C 作为结果,这是我的目标

0 投票
2 回答
1455 浏览

linux - gcc 4.x 不支持 x87​​ FPU 数学?

我一直在尝试从源代码编译 gcc 4.x,--with-fpmath=387但我收到了这个错误:"Invalid --with-fpmath=387". 我查看了配置,发现它不支持这个选项(尽管文档仍然提到它是一个可能的选项):

基本上,我开始这一切是因为我需要为旧的目标平台提供可执行文件(实际上,它是旧的 Celeron,但没有任何 SSE2 指令,显然由DEFAULT使用 libstdc++ )。可执行文件在来自 libstdc++ 中复制例程的第一条指令 (movq XMM0,...) 处崩溃,并显示“非法指令”消息。有没有办法解决这个问题?我需要使用相当新的 g++ 才能移植我现有的代码库。

我想知道是否可以从旧版本中提供这些标头/源以支持常规 x87 指令,从而不引用 SSE 指令?

更新:请注意我说的是编译后的 libstdc++ 在目标代码中有 SSE2 指令,所以问题不在于 gcc 命令行参数。无论我在编译我的代码时向 gcc 提供什么,它都会与已经具有内置 SSE2 指令的 libstdc++ 链接。

真正的答案是在编译 GCC 时不要使用任何--with-fpmath 开关。我被configure script switch语句弄糊涂了,以为它只支持sse或avx,而事实上,默认值(这个开关中没有提到是“387”)。因此,请确保在运行配置时不要使用 --with-fpmath。我在没有它的情况下重新编译了 GCC,它现在可以正常工作了。

谢谢。

0 投票
0 回答
675 浏览

assembly - Nasm fiadd 操作大小未指定错误

我使用 nasm 和FPUx86 指令。现在假设我有FPU st00。我有变量:

现在操作:

不起作用,nasm 中的错误:

什么时候:

,结果(当 st0 = 0 时)是:

而不是1 汇编代码:

C代码:

重要的线路,我跳的地方是 27,28:

如何解决?

0 投票
1 回答
282 浏览

assembly - 解释 FFREE 指令的工作原理

http://en.wikipedia.org/wiki/X86_instruction_listings

ffree 指令是如何工作的?当我在 FPU 堆栈中时免费注册:

然后在这些指令(ffree)之后我有..

那正确吗?

0 投票
2 回答
450 浏览

assembly - fstp 命令的使用

我有一个问题:假设我的浮点单元堆栈如下:

执行此指令后:

我的预测是该单元会将 st(0) 发送到 st(1) (堆栈上的情况将是1.5;1.5;2.5;0 etc)然后弹出堆栈的顶部,因此情况将是1.5;2.5;0 etc.

相反,我看到以下内容:

我的问题是,为什么st(7)发生了变化,我怎样才能达到预期的结果。谢谢你的帮助!