diff --git a/unittests/ASM/Known_Failures_host b/unittests/ASM/Known_Failures_host new file mode 100644 index 0000000000..322f758bca --- /dev/null +++ b/unittests/ASM/Known_Failures_host @@ -0,0 +1 @@ +Test_X87/FXAM_Simple.asm diff --git a/unittests/ASM/X87/FXAM_Push.asm b/unittests/ASM/X87/FXAM_Push.asm index a26e039bc8..d94511f3ca 100644 --- a/unittests/ASM/X87/FXAM_Push.asm +++ b/unittests/ASM/X87/FXAM_Push.asm @@ -11,7 +11,7 @@ mov rdx, 0xe0000000 ; This behaviour was seen around Wine 32-bit libraries ; Anything doing a call to a double application would spin ; the x87 stack on to the stack looking for fxam to return empty -; Empty in this case is that C0 and C3 is set whiel C2 is not +; Empty in this case is that C0 and C3 is set while C2 is not fninit ; Fill the x87 stack diff --git a/unittests/ASM/X87/FXAM_Push_2.asm b/unittests/ASM/X87/FXAM_Push_2.asm index c6ef4ff3fd..78edde24d3 100644 --- a/unittests/ASM/X87/FXAM_Push_2.asm +++ b/unittests/ASM/X87/FXAM_Push_2.asm @@ -11,7 +11,7 @@ mov rdx, 0xe0000000 ; This behaviour was seen around Wine 32-bit libraries ; Anything doing a call to a double application would spin ; the x87 stack on to the stack looking for fxam to return empty -; Empty in this case is that C0 and C3 is set whiel C2 is not +; Empty in this case is that C0 and C3 is set while C2 is not fninit ; Empty stack to make sure we don't push anything diff --git a/unittests/ASM/X87/FXAM_Push_Simple.asm b/unittests/ASM/X87/FXAM_Push_Simple.asm new file mode 100644 index 0000000000..de7ab5086f --- /dev/null +++ b/unittests/ASM/X87/FXAM_Push_Simple.asm @@ -0,0 +1,40 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "8" + } +} +%endif + +fninit +fld1 +fld1 +fld1 +fld1 +fld1 +fld1 +fld1 +fld1 + +mov ebx, 0 + +.ExamineStack: +; Examine st(0) +fxam +fwait +; Get the results in to AX +fnstsw ax +and ax, 0x4500 +; Check for empty +cmp ax, 0x4100 +je .Done + +; Now push the x87 stack value +; We know it isn't empty +fstp st0 +fwait +inc ebx +jmp .ExamineStack +.Done: +mov eax, ebx +hlt diff --git a/unittests/ASM/X87/FXAM_Push_Simple_2.asm b/unittests/ASM/X87/FXAM_Push_Simple_2.asm new file mode 100644 index 0000000000..429a0ae30c --- /dev/null +++ b/unittests/ASM/X87/FXAM_Push_Simple_2.asm @@ -0,0 +1,51 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "8" + } +} +%endif + +mov rdx, 0xe0000000 + +; This behaviour was seen around Wine 32-bit libraries +; Anything doing a call to a double application would spin +; the x87 stack on to the stack looking for fxam to return empty +; Empty in this case is that C0 and C3 is set while C2 is not + +fninit +; Fill the x87 stack +fldz +fldz +fldz +fldz +fldz +fldz +fldz +fldz + +mov eax, 0 +mov ecx, 0 + +.ExamineStack: +; Examine st(0) +fxam +fwait +; Get the results in to AX +fnstsw ax +and ax, 0x4500 +; Check for empty +cmp ax, 0x4100 +je .Done + +; Now push the x87 stack value +; We know it isn't empty +fstp qword [rdx + rcx * 8] +fwait +inc ecx +jmp .ExamineStack + +.Done: +; Save how many we stored +mov eax, ecx +hlt diff --git a/unittests/ASM/X87/FXAM_Simple.asm b/unittests/ASM/X87/FXAM_Simple.asm new file mode 100644 index 0000000000..7e76fbaaa3 --- /dev/null +++ b/unittests/ASM/X87/FXAM_Simple.asm @@ -0,0 +1,49 @@ +;; Simpler versions of FXAM_Push* tests. +;; In hostrunner tests this will fail because we mentioned below there's no support +;; for the zero flag. In hostrunner RCX should contain 0x4000 instead of 0x400. +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x6", + "RBX": "0x0400", + "RCX": "0x0400", + "RDX": "0x4100" + } +} +%endif + +mov rdx, 0xe0000000 + +fninit +;; Before adding anything to the stack, lets examine it. +;; The result should be empty. +fxam +fwait + +fnstsw ax +and ax, 0x4500 ; should be 0x4100 for zero +mov edx, eax + +fldz +fxam +fwait + +fnstsw ax +and ax, 0x4500 ; should be 0x4000 for zero, but there's no support for it at the moment, so it'll return 0x0400 as it does for a normal number. +mov ecx, eax + +fld1 +fxam +fwait + +fnstsw ax +mov ebx, eax +and ebx, 0x4500 ; should be 0x0400 for normal + +;; Top should be 6 +;; right shift status word by 11 and and with 0x7. +shr eax, 11 +and eax, 0x7 + + +hlt diff --git a/unittests/ASM/X87/Memcopy.asm b/unittests/ASM/X87/Memcopy.asm new file mode 100644 index 0000000000..47d299a203 --- /dev/null +++ b/unittests/ASM/X87/Memcopy.asm @@ -0,0 +1,21 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x3ff8000000000000", + "RBX": "0x3ff8000000000000" + }, + "MemoryRegions": { + "0x100000000": "4096" + } +} +%endif + +mov rdx, 0x100000000 +mov rax, 0x3ff8000000000000 ; 1.5 +mov [rdx], rax + +fld qword [rdx] +fstp qword [rdx + 8] + +mov rbx, [rdx + 8] +hlt diff --git a/unittests/ASM/x87_stack.asm b/unittests/ASM/x87_stack.asm new file mode 100644 index 0000000000..f032ca9c60 --- /dev/null +++ b/unittests/ASM/x87_stack.asm @@ -0,0 +1,26 @@ +%ifdef CONFIG +{ + "RegData": { + "RAX": "0x4142434445464748", + "RBX": "0" + } +} +%endif + +lea rax, [rel .data] +lea rbx, [rel .data_mov] + +fld qword [rax] +fstp qword [rbx] + +mov rax, [rbx] +mov rbx, [rbx + 8] +hlt + +.data: +dq 0x4142434445464748 +dq 0x5152535455565758 + +.data_mov: +dq 0 +dq 0 diff --git a/unittests/FEXLinuxTests/Known_Failures_Host b/unittests/FEXLinuxTests/Known_Failures_Host index e69de29bb2..81acd73a95 100644 --- a/unittests/FEXLinuxTests/Known_Failures_Host +++ b/unittests/FEXLinuxTests/Known_Failures_Host @@ -0,0 +1,2 @@ +## Unable to support zero flag +FXAM_Simple.asm