Merge pull request #4477 from pmatos/incdecstp-tests

Update tests for fincstp and fdecstp
This commit is contained in:
Ryan Houdek authored and GitHub committed 2025-04-04 09:37:56 -07:00
commit acfb24f871
6 files changed
+518 -166

No files matched your search

+88 -16
View File
@@ -1,30 +1,102 @@
%ifdef CONFIG
{
"RegData": {
"MM4": ["0x8000000000000000", "0x4001"],
"MM5": ["0x0000000000000000", "0x0000"],
"MM6": ["0x8000000000000000", "0x4000"],
"MM7": ["0x8000000000000000", "0x3FFF"]
"RAX": "7",
"RBX": "0",
"MM0": "0x3ff00000",
"MM1": "0x40700000",
"MM2": "0x40600000",
"MM3": "0x40500000",
"MM4": "0x40400000",
"MM5": "0x40300000",
"MM6": "0x40200000",
"MM7": "0x40000000"
},
"Mode": "32BIT"
}
%endif
lea edx, [.data]
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
fld qword [edx + 8 * 0]
fld qword [edx + 8 * 1]
section .bss
align 8
temp: resq 1
stack: resq 8
; Do Some stack shenanigans
fldz
fincstp
section .text
global _start
_start:
mov eax, 0x3ff00000 ; 1.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40000000 ; 2.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40200000 ; 4.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40300000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40400000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40500000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40600000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40700000
mov [rel temp], eax
fld dword [rel temp]
; Store top in ebx
xor eax, eax
xor ebx, ebx
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fdecstp
fld qword [edx + 8 * 2]
; Store top in RAX
xor eax, eax
fnstsw ax
shr ax, 11
and ax, 7
; Now ST0 is 0x3ff0000000000000
fstp dword [rel stack + 8 * 0]
fstp dword [rel stack + 8 * 1]
fstp dword [rel stack + 8 * 2]
fstp dword [rel stack + 8 * 3]
fstp dword [rel stack + 8 * 4]
fstp dword [rel stack + 8 * 5]
fstp dword [rel stack + 8 * 6]
fstp dword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt
.data:
dq 0x3ff0000000000000 ; 1.0
dq 0x4000000000000000 ; 2.0
dq 0x4010000000000000 ; 4.0
+89 -28
View File
@@ -1,40 +1,101 @@
%ifdef CONFIG
{
"RegData": {
"MM0": ["0x8000000000000000", "0x4007"],
"MM1": ["0x8000000000000000", "0x4006"],
"MM2": ["0x8000000000000000", "0x4005"],
"MM3": ["0x8000000000000000", "0x4004"],
"MM4": ["0x8000000000000000", "0x4003"],
"MM5": ["0x8000000000000000", "0x4002"],
"MM6": ["0x8000000000000000", "0x4000"],
"MM7": ["0x8000000000000000", "0x3FFF"]
"RAX": "1",
"RBX": "0",
"MM0": "0x40600000",
"MM1": "0x40500000",
"MM2": "0x40400000",
"MM3": "0x40300000",
"MM4": "0x40200000",
"MM5": "0x40000000",
"MM6": "0x3ff00000",
"MM7": "0x40700000"
},
"Mode": "32BIT"
}
%endif
lea edx, [.data]
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
fld qword [edx + 8 * 0]
fld qword [edx + 8 * 1]
fld qword [edx + 8 * 2]
fld qword [edx + 8 * 3]
fld qword [edx + 8 * 4]
fld qword [edx + 8 * 5]
fld qword [edx + 8 * 6]
fld qword [edx + 8 * 7]
section .bss
align 8
temp: resq 1
stack: resq 8
section .text
global _start
_start:
mov eax, 0x3ff00000 ; 1.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40000000 ; 2.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40200000 ; 4.0
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40300000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40400000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40500000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40600000
mov [rel temp], eax
fld dword [rel temp]
mov eax, 0x40700000
mov [rel temp], eax
fld dword [rel temp]
; Store top in RBX
xor eax, eax
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fincstp
; Store top in eax
xor eax, eax
fnstsw ax
shr ax, 11
and ax, 7
; Now ST0 is 0x4060000000000000
fstp dword [rel stack + 8 * 0]
fstp dword [rel stack + 8 * 1]
fstp dword [rel stack + 8 * 2]
fstp dword [rel stack + 8 * 3]
fstp dword [rel stack + 8 * 4]
fstp dword [rel stack + 8 * 5]
fstp dword [rel stack + 8 * 6]
fstp dword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt
.data:
dq 0x3ff0000000000000 ; 1.0
dq 0x4000000000000000 ; 2.0
dq 0x4020000000000000 ; 4.0
dq 0x4030000000000000
dq 0x4040000000000000
dq 0x4050000000000000
dq 0x4060000000000000
dq 0x4070000000000000
+85 -15
View File
@@ -1,31 +1,101 @@
%ifdef CONFIG
{
"RegData": {
"MM4": ["0x8000000000000000", "0x4001"],
"MM5": ["0x0000000000000000", "0x0000"],
"MM6": ["0x8000000000000000", "0x4000"],
"MM7": ["0x8000000000000000", "0x3FFF"]
"RAX": "7",
"RBX": "0",
"MM0": "0x3ff0000000000000",
"MM1": "0x4070000000000000",
"MM2": "0x4060000000000000",
"MM3": "0x4050000000000000",
"MM4": "0x4040000000000000",
"MM5": "0x4030000000000000",
"MM6": "0x4020000000000000",
"MM7": "0x4000000000000000"
}
}
%endif
mov rdx, 0xe0000000
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
section .bss
align 8
temp: resq 1
stack: resq 8
section .text
global _start
_start:
mov rax, 0x3ff0000000000000 ; 1.0
mov [rdx + 8 * 0], rax
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4000000000000000 ; 2.0
mov [rdx + 8 * 1], rax
mov rax, 0x4010000000000000 ; 4.0
mov [rdx + 8 * 2], rax
mov [rel temp], rax
fld qword [rel temp]
fld qword [rdx + 8 * 0]
fld qword [rdx + 8 * 1]
mov rax, 0x4020000000000000 ; 4.0
mov [rel temp], rax
fld qword [rel temp]
; Do Some stack shenanigans
fldz
fincstp
mov rax, 0x4030000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4040000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4050000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4060000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4070000000000000
mov [rel temp], rax
fld qword [rel temp]
; Store top in RBX
xor rax, rax
xor rbx, rbx
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fdecstp
fld qword [rdx + 8 * 2]
; Store top in RAX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
; Now ST0 is 0x3ff0000000000000
fstp qword [rel stack + 8 * 0]
fstp qword [rel stack + 8 * 1]
fstp qword [rel stack + 8 * 2]
fstp qword [rel stack + 8 * 3]
fstp qword [rel stack + 8 * 4]
fstp qword [rel stack + 8 * 5]
fstp qword [rel stack + 8 * 6]
fstp qword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt
+87 -32
View File
@@ -1,45 +1,100 @@
%ifdef CONFIG
{
"RegData": {
"MM0": ["0x8000000000000000", "0x4007"],
"MM1": ["0x8000000000000000", "0x4006"],
"MM2": ["0x8000000000000000", "0x4005"],
"MM3": ["0x8000000000000000", "0x4004"],
"MM4": ["0x8000000000000000", "0x4003"],
"MM5": ["0x8000000000000000", "0x4002"],
"MM6": ["0x8000000000000000", "0x4000"],
"MM7": ["0x8000000000000000", "0x3FFF"]
"RAX": "1",
"RBX": "0",
"MM0": "0x4060000000000000",
"MM1": "0x4050000000000000",
"MM2": "0x4040000000000000",
"MM3": "0x4030000000000000",
"MM4": "0x4020000000000000",
"MM5": "0x4000000000000000",
"MM6": "0x3ff0000000000000",
"MM7": "0x4070000000000000"
}
}
%endif
mov rdx, 0xe0000000
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
section .bss
align 8
temp: resq 1
stack: resq 8
section .text
global _start
_start:
mov rax, 0x3ff0000000000000 ; 1.0
mov [rdx + 8 * 0], rax
mov rax, 0x4000000000000000 ; 2.0
mov [rdx + 8 * 1], rax
mov rax, 0x4020000000000000 ; 4.0
mov [rdx + 8 * 2], rax
mov rax, 0x4030000000000000
mov [rdx + 8 * 3], rax
mov rax, 0x4040000000000000
mov [rdx + 8 * 4], rax
mov rax, 0x4050000000000000
mov [rdx + 8 * 5], rax
mov rax, 0x4060000000000000
mov [rdx + 8 * 6], rax
mov rax, 0x4070000000000000
mov [rdx + 8 * 7], rax
mov [rel temp], rax
fld qword [rel temp]
fld qword [rdx + 8 * 0]
fld qword [rdx + 8 * 1]
fld qword [rdx + 8 * 2]
fld qword [rdx + 8 * 3]
fld qword [rdx + 8 * 4]
fld qword [rdx + 8 * 5]
fld qword [rdx + 8 * 6]
fld qword [rdx + 8 * 7]
mov rax, 0x4000000000000000 ; 2.0
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4020000000000000 ; 4.0
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4030000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4040000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4050000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4060000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4070000000000000
mov [rel temp], rax
fld qword [rel temp]
; Store top in RBX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fincstp
; Store top in RAX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
; Now ST0 is 0x4060000000000000
fstp qword [rel stack + 8 * 0]
fstp qword [rel stack + 8 * 1]
fstp qword [rel stack + 8 * 2]
fstp qword [rel stack + 8 * 3]
fstp qword [rel stack + 8 * 4]
fstp qword [rel stack + 8 * 5]
fstp qword [rel stack + 8 * 6]
fstp qword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt
+83 -25
View File
@@ -1,44 +1,102 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x4010000000000000",
"RBX": "0x0",
"RCX": "0x4000000000000000",
"RDX": "0x3ff0000000000000"
"RAX": "7",
"RBX": "0",
"MM0": "0x3ff0000000000000",
"MM1": "0x4070000000000000",
"MM2": "0x4060000000000000",
"MM3": "0x4050000000000000",
"MM4": "0x4040000000000000",
"MM5": "0x4030000000000000",
"MM6": "0x4020000000000000",
"MM7": "0x4000000000000000"
},
"Env": { "FEX_X87REDUCEDPRECISION" : "1" }
}
%endif
mov rdx, 0xe0000000
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
section .bss
align 8
temp: resq 1
stack: resq 8
section .text
global _start
_start:
mov rax, 0x3ff0000000000000 ; 1.0
mov [rdx + 8 * 0], rax
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4000000000000000 ; 2.0
mov [rdx + 8 * 1], rax
mov rax, 0x4010000000000000 ; 4.0
mov [rdx + 8 * 2], rax
mov [rel temp], rax
fld qword [rel temp]
fld qword [rdx + 8 * 0]
fld qword [rdx + 8 * 1]
mov rax, 0x4020000000000000 ; 4.0
mov [rel temp], rax
fld qword [rel temp]
; Do Some stack shenanigans
fldz
fincstp
mov rax, 0x4030000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4040000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4050000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4060000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4070000000000000
mov [rel temp], rax
fld qword [rel temp]
; Store top in RBX
xor rax, rax
xor rbx, rbx
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fdecstp
fld qword [rdx + 8 * 2]
; Store top in RAX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
; dump stack to registers
mov r9, 0xe0000000
fstp qword [r9]
mov rax, [r9]
fstp qword [r9]
mov rbx, [r9]
fstp qword [r9]
mov rcx, [r9]
fstp qword [r9]
mov rdx, [r9]
; Now ST0 is 0x3ff0000000000000
fstp qword [rel stack + 8 * 0]
fstp qword [rel stack + 8 * 1]
fstp qword [rel stack + 8 * 2]
fstp qword [rel stack + 8 * 3]
fstp qword [rel stack + 8 * 4]
fstp qword [rel stack + 8 * 5]
fstp qword [rel stack + 8 * 6]
fstp qword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt
+86 -50
View File
@@ -1,65 +1,101 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x4060000000000000",
"RBX": "0x4050000000000000",
"RCX": "0x4040000000000000",
"RDX": "0x4030000000000000",
"R8": "0x4020000000000000",
"R9": "0x4000000000000000",
"R10": "0x3ff0000000000000",
"R11": "0x4070000000000000"
"RAX": "1",
"RBX": "0",
"MM0": "0x4060000000000000",
"MM1": "0x4050000000000000",
"MM2": "0x4040000000000000",
"MM3": "0x4030000000000000",
"MM4": "0x4020000000000000",
"MM5": "0x4000000000000000",
"MM6": "0x3ff0000000000000",
"MM7": "0x4070000000000000"
},
"Env": { "FEX_X87REDUCEDPRECISION" : "1" }
}
%endif
mov rdx, 0xe0000000
; Set the stack with different values.
; Then do fincstp and store the stack values into MMX registers through memory
; such that MM0 has the value of ST0 and so on.
section .bss
align 8
temp: resq 1
stack: resq 8
section .text
global _start
_start:
mov rax, 0x3ff0000000000000 ; 1.0
mov [rdx + 8 * 0], rax
mov rax, 0x4000000000000000 ; 2.0
mov [rdx + 8 * 1], rax
mov rax, 0x4020000000000000 ; 4.0
mov [rdx + 8 * 2], rax
mov rax, 0x4030000000000000
mov [rdx + 8 * 3], rax
mov rax, 0x4040000000000000
mov [rdx + 8 * 4], rax
mov rax, 0x4050000000000000
mov [rdx + 8 * 5], rax
mov rax, 0x4060000000000000
mov [rdx + 8 * 6], rax
mov rax, 0x4070000000000000
mov [rdx + 8 * 7], rax
mov [rel temp], rax
fld qword [rel temp]
fld qword [rdx + 8 * 0]
fld qword [rdx + 8 * 1]
fld qword [rdx + 8 * 2]
fld qword [rdx + 8 * 3]
fld qword [rdx + 8 * 4]
fld qword [rdx + 8 * 5]
fld qword [rdx + 8 * 6]
fld qword [rdx + 8 * 7]
mov rax, 0x4000000000000000 ; 2.0
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4020000000000000 ; 4.0
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4030000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4040000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4050000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4060000000000000
mov [rel temp], rax
fld qword [rel temp]
mov rax, 0x4070000000000000
mov [rel temp], rax
fld qword [rel temp]
; Store top in RBX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
mov bx, ax
; Move the value of stop
; ST0 is currently 0x4070000000000000
fincstp
; dump stack to registers
mov r12, 0xe0000000
fstp qword [r12]
mov rax, [r12]
fstp qword [r12]
mov rbx, [r12]
fstp qword [r12]
mov rcx, [r12]
fstp qword [r12]
mov rdx, [r12]
fstp qword [r12]
mov r8, [r12]
fstp qword [r12]
mov r9, [r12]
fstp qword [r12]
mov r10, [r12]
fstp qword [r12]
mov r11, [r12]
; Store top in RAX
xor rax, rax
fnstsw ax
shr ax, 11
and ax, 7
; Now ST0 is 0x4060000000000000
fstp qword [rel stack + 8 * 0]
fstp qword [rel stack + 8 * 1]
fstp qword [rel stack + 8 * 2]
fstp qword [rel stack + 8 * 3]
fstp qword [rel stack + 8 * 4]
fstp qword [rel stack + 8 * 5]
fstp qword [rel stack + 8 * 6]
fstp qword [rel stack + 8 * 7]
movq mm0, [rel stack + 8 * 0]
movq mm1, [rel stack + 8 * 1]
movq mm2, [rel stack + 8 * 2]
movq mm3, [rel stack + 8 * 3]
movq mm4, [rel stack + 8 * 4]
movq mm5, [rel stack + 8 * 5]
movq mm6, [rel stack + 8 * 6]
movq mm7, [rel stack + 8 * 7]
hlt