From a07b234659e7c9ca13db8270f1048600bbe039bb Mon Sep 17 00:00:00 2001 From: Paulo Matos Date: Wed, 30 Jul 2025 09:52:20 +0200 Subject: [PATCH] asm_tests: Tests for fninit NFC. These tests existed for 32bits but were missing for 64bits and reduced precision. Adjust 32bit test to match new tests. --- unittests/32Bit_ASM/X87/DB_E3.asm | 12 ++++++++---- unittests/ASM/X87/DB_E3.asm | 21 +++++++++++++++++++++ unittests/ASM/X87_F64/DB_E3.asm | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 unittests/ASM/X87/DB_E3.asm create mode 100644 unittests/ASM/X87_F64/DB_E3.asm diff --git a/unittests/32Bit_ASM/X87/DB_E3.asm b/unittests/32Bit_ASM/X87/DB_E3.asm index e2f7c74e7..d38ab1ce9 100644 --- a/unittests/32Bit_ASM/X87/DB_E3.asm +++ b/unittests/32Bit_ASM/X87/DB_E3.asm @@ -7,12 +7,16 @@ } %endif -mov eax, 0 -mov esp, 0xe0000008 +section .bss +control: resb 2 ; Reserve space for the FPU control word + +section .text +global _start +_start: fninit ; Ensures that fnstcw after fninit sets the correct value -fnstcw [esp] -mov ax, word [esp] +fnstcw [rel control] +mov ax, word [rel control] hlt diff --git a/unittests/ASM/X87/DB_E3.asm b/unittests/ASM/X87/DB_E3.asm new file mode 100644 index 000000000..17db1e88b --- /dev/null +++ b/unittests/ASM/X87/DB_E3.asm @@ -0,0 +1,21 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x037F" + } +} +%endif + +section .bss +control: resb 2 ; Reserve space for the FPU control word + +section .text +global _start +_start: +fninit + +; Ensures that fnstcw after fninit sets the correct value +fnstcw [rel control] +mov ax, word [rel control] + +hlt diff --git a/unittests/ASM/X87_F64/DB_E3.asm b/unittests/ASM/X87_F64/DB_E3.asm new file mode 100644 index 000000000..39613ab6e --- /dev/null +++ b/unittests/ASM/X87_F64/DB_E3.asm @@ -0,0 +1,22 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x037F" + }, + "Env": { "FEX_X87REDUCEDPRECISION" : "1" } +} +%endif + +section .bss +control: resb 2 ; Reserve space for the FPU control word + +section .text +global _start +_start: +fninit + +; Ensures that fnstcw after fninit sets the correct value +fnstcw [rel control] +mov ax, word [rel control] + +hlt