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: 669
Location: Ukraine
Overclick 09 May 2021, 21:09
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: 20451
Location: In your JS exploiting you and your system
revolution 09 May 2021, 21:30
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: 669
Location: Ukraine
Overclick 09 May 2021, 22:22
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: 20451
Location: In your JS exploiting you and your system
revolution 10 May 2021, 00:44
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: 1228
Location: Belarus
DimonSoft 10 May 2021, 20:04
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.