flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > [solved] How to use FPU flags for jumps?

Author
Thread Post new topic Reply to topic
Overclick



Joined: 11 Jul 2020
Posts: 391
Location: Ukraine
Overclick
Hi
Could someone show some example code?
As I understand I have to migrate the flags form FPU to CPU or what?


Last edited by Overclick on 09 May 2021, 22:22; edited 1 time in total
Post 09 May 2021, 21:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18182
Location: In your JS exploiting you and your system
revolution
The instruction you probably want is FSTSW AX.

And if you are in 32-bit code, then SAHF to transfer them to EFLAGS. The FPU flags line up with the CPU well. It was designed with this sequence in mind.
Post 09 May 2021, 21:30
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 391
Location: Ukraine
Overclick
Thanks man
Post 09 May 2021, 22:22
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18182
Location: In your JS exploiting you and your system
revolution
Also, if your target CPUs are all AMD or Intel, and produced after aprox. December 2005, then it supports SAHF in 64-bit mode.

Windows 8.1 and later require the CPU to support 64-bit SAHF, so if your target OSes are one of those then it will be fine.
Post 10 May 2021, 00:44
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 954
Location: Belarus
DimonSoft
Also there’re fcomi[p] instructions which set EFLAGS directly according to comparison result. Emulator support is quite poor though (AFAIR, DOSBox is bad at emulating them for DOS programs).
Post 10 May 2021, 20:04
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.