NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: ben321 on October 10, 2022, 05:45:28 AM
-
If I do a comparison operation like "TEST EAX,EAX", the result of that operation is unfortunately not stored in any normal accessible register like ECX or whatever. Instead it's stored in the Zero Flag bit of the CPU status register. This works great when using a conditional jump instruction (like JNE), which internally looks at such flag bits. However what if I want to just extract ZF bit for further usage that DOESN'T involve a conditional jump, how do I do that? For example, how do I store the ZF bit in the lowest bit of the EAX register? I don't know if there's any kind of GetZeroFlagBit instruction in x86 assembly.
-
pushf
pop eax ; or other reg
Best,
Frank
-
Hi again Ben,
I should have said... You probably don't want to do this. Probably better to save the "mystery value" and test it for zero when you're ready to use the result than to test it now and save the result. But if you want to, "pushf"...
Best,
Frank
-
setz al ; al = 0 if ZF=0, 1 if ZF=1
-
We live and learn! Thank you, Fred!
Best,
Frank