Skip to content

Commit 2043212

Browse files
committed
[INTERPRETER] Fixed D9 F4 opcode ([DYNAREC] too) (backported from box64)
1 parent e754df0 commit 2043212

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/dynarec/dynarec_arm_functions.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,20 @@ void arm_fpatan(x86emu_t* emu)
6262
}
6363
void arm_fxtract(x86emu_t* emu)
6464
{
65-
int32_t tmp32s = (ST1.q&0x7ff0000000000000LL)>>52;
66-
tmp32s -= 1023;
67-
ST1.d /= exp2(tmp32s);
68-
ST0.d = tmp32s;
65+
int tmp32s;
66+
if(isnan(ST1.d)) {
67+
ST0.d = ST1.d;
68+
} else if(isinf(ST1.d)) {
69+
ST0.d = ST1.d;
70+
ST1.d = INFINITY;
71+
} else if(ST1.d==0.0) {
72+
ST0.d = ST1.d;
73+
ST1.d = -INFINITY;
74+
} else {
75+
// LD80bits doesn't have implicit "1" bit, so need to adjust for that
76+
ST0.d = frexp(ST1.d, &tmp32s)*2;
77+
ST1.d = tmp32s-1;
78+
}
6979
}
7080
void arm_fprem(x86emu_t* emu)
7181
{

src/emu/x86rund9.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,20 @@ uintptr_t RunD9(x86emu_t *emu, uintptr_t addr)
144144
emu->sw.f.F87_C1 = 0;
145145
break;
146146
case 0xF4: /* FXTRACT */
147-
ST0.d = frexp(ST0.d, &tmp32s);
148147
fpu_do_push(emu);
149-
ST0.d = tmp32s;
148+
if(isnan(ST1.d)) {
149+
ST0.d = ST1.d;
150+
} else if(isinf(ST1.d)) {
151+
ST0.d = ST1.d;
152+
ST1.d = INFINITY;
153+
} else if(ST1.d==0.0) {
154+
ST0.d = ST1.d;
155+
ST1.d = -INFINITY;
156+
} else {
157+
// LD80bits doesn't have implicit "1" bit, so need to adjust for that
158+
ST0.d = frexp(ST1.d, &tmp32s)*2;
159+
ST1.d = tmp32s-1;
160+
}
150161
// C1 set only if stack under/overflow occurs
151162
break;
152163

0 commit comments

Comments
 (0)