From 381ce23fd76d0f874d48d3fac7e336805fc9c66c Mon Sep 17 00:00:00 2001 From: Paulo Matos Date: Tue, 9 Jul 2024 13:36:16 +0200 Subject: [PATCH] Tests for X87 FTST --- unittests/ASM/X87/D9_E4.asm | 35 ++++++++++++++++++++++++++++ unittests/ASM/X87_F64/D9_E4_F64.asm | 36 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 unittests/ASM/X87/D9_E4.asm create mode 100644 unittests/ASM/X87_F64/D9_E4_F64.asm diff --git a/unittests/ASM/X87/D9_E4.asm b/unittests/ASM/X87/D9_E4.asm new file mode 100644 index 000000000..fcefd8750 --- /dev/null +++ b/unittests/ASM/X87/D9_E4.asm @@ -0,0 +1,35 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x100", + "RBX": "0x0", + "RCX": "0x4000" + }, + "MemoryRegions": { + "0x100000000": "4096" + } +} +%endif + +fld dword [rel positive] +ftst +fnstsw ax +and rax, 0x4700 +mov rbx, rax + +fldz +ftst +fnstsw ax +and rax, 0x4700 +mov rcx, rax + +fld dword [rel negative] +ftst +fnstsw ax +and rax, 0x4700 + +hlt + +align 16 +positive: dd 3.14159 +negative: dd -2.71828 \ No newline at end of file diff --git a/unittests/ASM/X87_F64/D9_E4_F64.asm b/unittests/ASM/X87_F64/D9_E4_F64.asm new file mode 100644 index 000000000..ce5687622 --- /dev/null +++ b/unittests/ASM/X87_F64/D9_E4_F64.asm @@ -0,0 +1,36 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x100", + "RBX": "0x0", + "RCX": "0x4000" + }, + "MemoryRegions": { + "0x100000000": "4096" + }, + "Env": { "FEX_X87REDUCEDPRECISION" : "1" } +} +%endif + +fld dword [rel positive] +ftst +fnstsw ax +and rax, 0x4700 +mov rbx, rax + +fldz +ftst +fnstsw ax +and rax, 0x4700 +mov rcx, rax + +fld dword [rel negative] +ftst +fnstsw ax +and rax, 0x4700 + +hlt + +align 8 +positive: dd 3.14159 +negative: dd -2.71828 \ No newline at end of file