From 4e2220c27f92e09a32eb5bd2d0bb1d8e076f1d06 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 11 Jan 2022 01:19:10 -0800 Subject: [PATCH] unittests: Adds ptest unit test to ensure correct flag setting ptest wasn't correctly setting OF, SF, AF, and PF to zero until now. Do a unit test to ensure correct behaviour here --- unittests/ASM/H0F38/66_17_2.asm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 unittests/ASM/H0F38/66_17_2.asm diff --git a/unittests/ASM/H0F38/66_17_2.asm b/unittests/ASM/H0F38/66_17_2.asm new file mode 100644 index 000000000..02dff1fc7 --- /dev/null +++ b/unittests/ASM/H0F38/66_17_2.asm @@ -0,0 +1,32 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0xFFFFFFFFFFFF43FF", + "RBX": "0" + } +} +%endif + +; Set EFLAGS to known value with sahf +mov rax, -1 +sahf + +movups xmm0, [rel .data] +; Tests a bug that FEX had where ptest would not set OF, SF, AF, PF to zero +ptest xmm0, xmm0 + +; Now load back +; ZF = 1 +; CF = 1 +; OF, SF, AF, PF should be zero +lahf + +; lahf doesn't get OF, get it with seto +mov rbx, 0 +seto bl + +hlt + +.data: +dq 0 +dq 0