Implementation of FCNLEX to clear IE flag

This commit is contained in:
Paulo Matos committed 2025-07-30 10:50:16 +02:00
1 parent ac420347d1
commit ee1725684a
6 files changed
+85 -2

No files matched your search

@@ -5545,7 +5545,7 @@ void InstallOpcodeHandlers(Context::OperatingMode Mode) {
{OPD(0xDB, 0xD0), 8, &OpDispatchBuilder::X87FCMOV},
{OPD(0xDB, 0xD8), 8, &OpDispatchBuilder::X87FCMOV},
// E0 = Invalid
{OPD(0xDB, 0xE2), 1, &OpDispatchBuilder::NOPOp}, // FNCLEX
{OPD(0xDB, 0xE2), 1, &OpDispatchBuilder::FNCLEX},
{OPD(0xDB, 0xE3), 1, &OpDispatchBuilder::FNINIT},
// E4 = Invalid
{OPD(0xDB, 0xE8), 8,
@@ -5804,7 +5804,7 @@ void InstallOpcodeHandlers(Context::OperatingMode Mode) {
{OPD(0xDB, 0xD0), 8, &OpDispatchBuilder::X87FCMOV},
{OPD(0xDB, 0xD8), 8, &OpDispatchBuilder::X87FCMOV},
// E0 = Invalid
{OPD(0xDB, 0xE2), 1, &OpDispatchBuilder::NOPOp}, // FNCLEX
{OPD(0xDB, 0xE2), 1, &OpDispatchBuilder::FNCLEX},
{OPD(0xDB, 0xE3), 1, &OpDispatchBuilder::FNINIT},
// E4 = Invalid
{OPD(0xDB, 0xE8), 8,
@@ -735,6 +735,7 @@ public:
void FADD(OpcodeArgs, IR::OpSize Width, bool Integer, OpResult ResInST0);
void FDIV(OpcodeArgs, IR::OpSize Width, bool Integer, bool Reverse, OpResult ResInST0);
void FMUL(OpcodeArgs, IR::OpSize Width, bool Integer, OpResult ResInST0);
void FNCLEX(OpcodeArgs);
void FNINIT(OpcodeArgs);
void FSUB(OpcodeArgs, IR::OpSize Width, bool Integer, bool Reverse, OpResult ResInST0);
void FTST(OpcodeArgs);
@@ -759,6 +759,11 @@ void OpDispatchBuilder::X87FNSTSW(OpcodeArgs) {
StoreResult(GPRClass, Op, StatusWord, OpSize::iInvalid);
}
void OpDispatchBuilder::FNCLEX(OpcodeArgs) {
// Clear the exception flag bit
SetRFLAG<FEXCore::X86State::X87FLAG_IE_LOC>(_Constant(0));
}
void OpDispatchBuilder::FNINIT(OpcodeArgs) {
auto Zero = _Constant(0);
+26
View File
@@ -0,0 +1,26 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0",
"RBX": "1"
},
"Mode": "32BIT"
}
%endif
finit ; IOC is 0
fldz
fld1
fdiv st0, st1 ; IOC is 1
fnstsw ax
and eax, 1
mov ebx, eax ; save IOC to RBX
; Clear
fnclex
fnstsw ax
and eax, 1
hlt
+25
View File
@@ -0,0 +1,25 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0",
"RBX": "1"
}
}
%endif
finit ; IOC is 0
fldz
fld1
fdiv st0, st1 ; IOC is 1
fnstsw ax
and rax, 1
mov rbx, rax ; save IOC to RBX
; Clear
fnclex
fnstsw ax
and rax, 1
hlt
+26
View File
@@ -0,0 +1,26 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0",
"RBX": "1"
},
"Env": { "FEX_X87REDUCEDPRECISION" : "1" }
}
%endif
finit ; IOC is 0
fldz
fld1
fdiv st0, st1 ; IOC is 1
fnstsw ax
and rax, 1
mov rbx, rax ; save IOC to RBX
; Clear
fnclex
fnstsw ax
and rax, 1
hlt