关于FPU

关于FPU,比较运算有几个地方需要关注,mark一下。

he result of the comparison is reported in the condition codes field of the Status Word as follows (the C1 bit is not used and the C2 bit was not used in early FPUs):

                           C3   C2   C0  |  ZF  PF  CF
     If ST(0) > source      0    0    0  |  0   0  0
     If ST(0) < source      0    0    1  |  0   0  1
     If ST(0) = source      1    0    0  |  1   0  0
     If ST(0) ? source      1    1    1  |

An Invalid operation exception is detected if ST(0) is empty, or if a data register specified as the source is empty, or if one of the two values is a NAN, setting the related flag in the Status Word. The result would then be indeterminate and return C3=1, C2=1 and C0=1 as indicated above. (Values of INFINITY will be treated as valid operands and yield a valid result without any exception being detected.)

主要是三种比较方式

1、fnstsw ax, c3 / c2 / c0 分别放到AH的0 / 2 / 6位,test ah, 5,只看c0 / c2,c0 / c2 都为1 或都为0, PF =1 , JP跳转

2、fnstsw ax,同上,test ah, 41h,根据比较结果进行判断,JZ / JNZ跳转。

3、fnstsw ax,c3 / c2 / c0对应ZF / PF / CF,setnbe al, al = 1 如果CF =0 ,ZF=0,然后test al, al,JZ/JNZ

变种:fnstsw ax , sahf(将AH对应ZF/PF/CF寄存器值),JA跳转,如果ZF=0 AND CF=0

4、P6 Intel family,使用能改变寄存器的指令,不需要转换。

FUCOMI / FCMOVBE ….

参考链接:

http://www.website.masmforum.com/tutorials/fptute/fpuchap7.htm

转载于:https://www.cnblogs.com/f3ngt1ng/p/7427733.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值