简体   繁体   English

FCOM在Turbo汇编器中不起作用

[英]FCOM doesn't work in Turbo Assembler

I have a problem with comparison in tasm. 我在tasm中进行比较时遇到问题。 I have a code 我有一个密码

cycle:
...some code...
fninit
fld limit
fld currentX    
fcom st(1)
jge exit
jmp cycle

But it jumps to exit mark even if conditions aren't met. 但是,即使不满足条件,它也会跳到退出标记。 I check it in turbo debugger and fpu stack values are right. 我在涡轮调试器中检查了它,并且fpu堆栈值正确。 How to fix it? 如何解决?

fcom only sets fpu status bits, not the cpu flags so you can't directly use a conditional jump. fcom仅设置fpu状态位,而不设置cpu标志,因此您不能直接使用条件跳转。 There is an fcomi instruction which does, but that's only available when using a P6+ cpu and an assembler that understands such instructions. 有一个fcomi指令可以执行,但仅在使用P6 + cpu和可理解此类指令的汇编器时才可用。 According to Michael Petch, for tasm you need at least version 5.3. 根据Michael Petch的说法,要实现tasm,至少需要5.3版。 A workaround is to transfer the fpu status bits to cpu flags using fstsw ax and sahf . 解决方法是使用fstsw axsahf将fpu状态位传输到cpu标志。

Also note that in either case, the relevant fpu status bits C0 , C2 and C3 get transferred to CF , PF and ZF respectively, so you should use a conditional jump that checks these flags. 还要注意,在任何一种情况下,相关的fpu状态位C0C2C3分别传输到CFPFZF ,因此您应该使用条件跳转来检查这些标志。 In your case this means jae . 就您而言,这就是jae

See also section 8.1.4 Branching and Conditional Moves on Condition Codes in the Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture and of course the instruction set reference as usual. 另请参阅《 英特尔®64和IA-32体系结构软件开发人员手册》第1卷:基础架构中的条件代码中的分支和条件移动部分8.1.4,以及与往常一样的指令集参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM