关于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 CFIf ST(0) > source 0 0 0 | 0 0 0If ST(0) < source 0 0 1 | 0 0 1If ST(0) = source 1 0 0 | 1 0 0If 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
總結
- 上一篇: java-循环语句
- 下一篇: Distcp 分布式拷贝