本文介绍了英特尔x86_64的装配比较签订双precision花车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会根据拍摄主体有问题。

I've got a problem according to subject.

在XMM0寄存器我有一个值,F.E. :-512.000000
而在XMM4:0.000000

In xmm0 register I have a value, f.e. : -512.000000And in xmm4 : 0.000000.

我尝试比较第一个值零,我真的不能做到这一点。

I try to compare first value with zero and I cannot really achieve this.

comisd xmm0, xmm4

COMISD指令设置在陌生的路上标志,只有JNZ在我的code正常工作后。
我怎么能这样做比较呢?

COMISD instruction sets flags in a strange way, and only jnz after that works properly in my code.How can I do this comparison?

推荐答案

英特尔手册记录如何设置标志。

Intel's manual documents how COMISD sets flags.

首先,检查无序与 JP (如果你希望你的code到楠投入正常工作)。

First, check for unordered with a jp (if you want your code to work properly for NaN inputs).

然后你可以使用任何的 JA / / JB的 / 乙脑(上/下)条件或他们的底片( JNA 等),或 JE / JNE (等于/不等于)。这些都是相同的条件,作为无符号整数进行比较。很显然,CMOV和setcc工作了。

Then you can use any of the ja / jae / jb / jbe (above / below) conditions or their negatives (jna, etc), or je / jne (equal / not-equal). These are the same conditions as for unsigned integer compares. And obviously cmov and setcc work too.

这些条件有一个像 JC 同义词(跳跃如果CF == 1),但高于/低于有正确语义,所以可以减少所需的评论的数量让你的code人类可读的。

These conditions have synonyms like jc (jump if CF==1), but above/below have the right semantic meaning, so can reduce the amount of comments necessary to make your code human-readable.

您可以跳过 JP JA 的条件之前,因为CF = 0意味着PF = 0。 (即 A 的条件将是错误的,如果操作数是无序的。其他一些条件,如 AE ,将是真正的无序操作数,所以你需要在 JP分支之前或之后如果你需要排除NaN的输入)

You can skip the jp before a condition like ja, because CF=0 implies PF=0. (i.e. the a condition will be false if the operands were unordered. Some Other conditions, like ae, will be true for unordered operands, so you need to branch on jp before or after jae if you need to rule out NaN inputs).

注意 comisd 的标记设置相匹配你的x87得到什么 FCOM /的 /的。另请参见的例子。但是,只有历史的兴趣! ,这也设置标志以同样的方式,已经出现了超过20年(P6),以及更快。 (见标签的wiki)。

Note that comisd's flag-setting matches what you get from x87 fcom / fnstsw ax / sahf. See also this x87 tutorial/guide for an example of using that sequence. But only for historical interest! fcomi, which also sets the flags the same way, has been around for over 20 years (P6), and is faster. (See the x86 tag wiki for more links).

的x87仅适用于80位扩展precision有用,因为它通常是安全的假设,SSE2是可用的,即使是在32位模式。

x87 is only useful for 80 bit extended precision, since it's generally safe to assume that SSE2 is available, even in 32bit mode.

这篇关于英特尔x86_64的装配比较签订双precision花车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:19