Skip to content

Commit

Permalink
Tests: X87 Refactoring and Pass
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatos committed Jul 19, 2024
1 parent 5c5c921 commit 8c0e3c0
Show file tree
Hide file tree
Showing 13 changed files with 1,328 additions and 2 deletions.
1 change: 1 addition & 0 deletions unittests/ASM/Known_Failures_host
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test_X87/FXAM_Simple.asm
2 changes: 1 addition & 1 deletion unittests/ASM/X87/FXAM_Push.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion unittests/ASM/X87/FXAM_Push_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions unittests/ASM/X87/FXAM_Push_Simple.asm
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions unittests/ASM/X87/FXAM_Push_Simple_2.asm
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions unittests/ASM/X87/FXAM_Simple.asm
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions unittests/ASM/X87/Memcopy.asm
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions unittests/ASM/x87_stack.asm
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions unittests/FEXLinuxTests/Known_Failures_Host
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Unable to support zero flag
FXAM_Simple.asm
Loading

0 comments on commit 8c0e3c0

Please sign in to comment.