From 58a034b79ded8910ca0833c7eec01939333035c4 Mon Sep 17 00:00:00 2001 From: Paulo Matos Date: Mon, 13 Jan 2025 18:18:56 +0100 Subject: [PATCH] asm_tests: x87 fst/fld optimization for different addrmodes --- unittests/32Bit_ASM/X87/FST_AddrModes.asm | 44 +++++++++++++++++++++++ unittests/ASM/X87/DB_07_2.asm | 25 +++++++++++++ unittests/ASM/X87/FST_AddrModes.asm | 43 ++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 unittests/32Bit_ASM/X87/FST_AddrModes.asm create mode 100644 unittests/ASM/X87/DB_07_2.asm create mode 100644 unittests/ASM/X87/FST_AddrModes.asm diff --git a/unittests/32Bit_ASM/X87/FST_AddrModes.asm b/unittests/32Bit_ASM/X87/FST_AddrModes.asm new file mode 100644 index 0000000000..93d5bb678c --- /dev/null +++ b/unittests/32Bit_ASM/X87/FST_AddrModes.asm @@ -0,0 +1,44 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x3f800000", + "RBX": "0x3f800000", + "RCX": "0x3f800000", + "RBP": "0x3f800000", + "RDI": "0x3f800000", + "RSP": "0x3f800000" + }, + "MemoryRegions": { + "0xf0000000": "4096" + }, + "Mode": "32BIT" +} +%endif + +section .bss +base resb 4096 + +section .text + +; Setup +fld1 +lea edx, [rel base] +mov esi, 0x64 + +; Test fst +fst dword [edx] +fst dword [edx + 0xa] +fst dword [edx + esi] +fst dword [edx + esi * 4] +fst dword [edx + esi + 0xa] +fst dword [edx + esi * 4 + 0xa] + +; Result check +mov eax, dword [edx] +mov ebx, dword [edx + 0xa] +mov ecx, dword [edx + esi] +mov ebp, dword [edx + esi * 4] +mov edi, dword [edx + esi + 0xa] +mov esp, dword [edx + esi * 4 + 0xa] + +hlt diff --git a/unittests/ASM/X87/DB_07_2.asm b/unittests/ASM/X87/DB_07_2.asm new file mode 100644 index 0000000000..865390654c --- /dev/null +++ b/unittests/ASM/X87/DB_07_2.asm @@ -0,0 +1,25 @@ +%ifdef CONFIG +{ + "RegData": { + "MM7": ["0x8000000000000000", "0x4000"] + } +} +%endif + +lea rdx, [rel data] +fld tword [rdx + 8 * 0] + +lea rdx, [rel data2] +lea rax, [rdx + 8 * 0] +fstp tword [rax] +fld tword [rdx + 8 * 0] + +hlt + +align 8 +data: + dt 2.0 + dq 0 +data2: + dt 0.0 + dq 0 diff --git a/unittests/ASM/X87/FST_AddrModes.asm b/unittests/ASM/X87/FST_AddrModes.asm new file mode 100644 index 0000000000..87fc46387c --- /dev/null +++ b/unittests/ASM/X87/FST_AddrModes.asm @@ -0,0 +1,43 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x3f800000", + "RBX": "0x3f800000", + "RCX": "0x3f800000", + "R8": "0x3f800000", + "R9": "0x3f800000", + "R10": "0x3f800000" + }, + "MemoryRegions": { + "0x100000000": "4096" + } +} +%endif + +section .bss +base resb 4096 + +section .text + +; Setup +fld1 +lea rdx, [rel base] +mov rsi, 0x64 + +; Test fst +fst dword [rdx] +fst dword [rdx + 0xa] +fst dword [rdx + rsi] +fst dword [rdx + rsi * 4] +fst dword [rdx + rsi + 0xa] +fst dword [rdx + rsi * 4 + 0xa] + +; Result check +mov eax, dword [rdx] +mov ebx, dword [rdx + 0xa] +mov ecx, dword [rdx + rsi] +mov r8d, dword [rdx + rsi * 4] +mov r9d, dword [rdx + rsi + 0xa] +mov r10d, dword [rdx + rsi * 4 + 0xa] + +hlt