Assembly ASM jbe不工作(fpu)

Assembly ASM jbe不工作(fpu),assembly,Assembly,我想比较堆栈上的浮点值(st(0))和变量temp中的值。 为什么jae工作良好(跳到@Next),而jbe不跳到@Next2 mov te, 254 fild te; mov rax, 0; mov temp, 0 fcom temp; fstsw ax; SAHF; jae @Next mov byte ptr [rcx], 0; ret; @Next: mov rax, 0 mov temp, 255 fcom temp; f

我想比较堆栈上的浮点值(st(0))和变量temp中的值。 为什么jae工作良好(跳到@Next),而jbe不跳到@Next2

mov     te, 254
fild    te;
mov     rax, 0;
mov     temp, 0
fcom    temp;
fstsw   ax;
SAHF;
jae @Next
mov byte ptr [rcx], 0;
ret;

@Next:
mov     rax, 0
mov     temp, 255
fcom    temp;
fstsw   ax;
SAHF;
jbe     @Next2
mov byte ptr [rcx], 255
ret;

@Next2:
fistp   word ptr [rcx];
这将不起作用,因为
fcom
需要浮点操作数,而您为其提供的是整数操作数。对于值0,这恰好起作用,因为
0x00000000
0.0
具有相同的位模式

解决此问题的一种方法是将
fcom
更改为
ficom

ficom word ptr [temp]  ; or dword ptr, depending on the size of temp
这将不起作用,因为
fcom
需要浮点操作数,而您为其提供的是整数操作数。对于值0,这恰好起作用,因为
0x00000000
0.0
具有相同的位模式

解决此问题的一种方法是将
fcom
更改为
ficom

ficom word ptr [temp]  ; or dword ptr, depending on the size of temp

既然您的分支只依赖于进位标志,为什么不将
fcom
+
fstsw
+
sahf
替换为
fcomi
?@Michael它会更快吗(我需要推堆栈、fcomi和pop)?既然您的分支只依赖于进位标志,为什么不将
fcom
+
fstsw
+
sahf
替换为
fcomi
?@Michael它会更快吗(我需要推动堆栈、fcomi和pop)?