Fixed IDIV on 286+ again, fixes Windows 95.

This commit is contained in:
OBattler
2017-12-14 04:38:33 +01:00
parent 28426e53af
commit 67cc1b42e6
2 changed files with 37 additions and 24 deletions

View File

@@ -463,17 +463,18 @@ int divl(uint32_t val)
}
int idivl(int32_t val)
{
uint64_t tempsrc;
int64_t tempws, tempws2 = 0;
uint64_t templ;
int64_t tempsrc, tempws, tempws2 = 0;
if (val == 0) {
divexcp(); /* Divide by zero. */
return 1;
}
tempsrc = (uint64_t) EDX;
tempsrc = (tempsrc << 32) | EAX;
tempws = ((int64_t)tempsrc) / ((int64_t)((int32_t)val));
templ = (uint64_t) EDX;
templ = (templ << 32) | EAX;
tempsrc = (int64_t) templ;
tempws = tempsrc / val;
if ((tempws > 2147483647LL) || (tempws < -2147483648LL)) {
divexcp();
@@ -481,10 +482,10 @@ int idivl(int32_t val)
}
tempws = (int32_t) tempws;
tempws2 = (int32_t) ((int64_t)tempsrc) % ((int64_t)((int32_t)val));
tempws2 = (int32_t) (templ % val);
DX = (uint32_t) tempws2;
AX = (uint32_t) tempws;
EDX = (int32_t) tempws2;
EAX = (int32_t) tempws;
return 0;
}

View File

@@ -64,7 +64,7 @@ static int opSETALC(uint32_t fetchdat)
static int opF6_a16(uint32_t fetchdat)
{
int32_t tempws, tempws2 = 0;
int32_t tempsrc, tempdst, tempws, tempws2 = 0;
uint16_t tempw, src16;
uint8_t src, dst;
@@ -135,7 +135,10 @@ static int opF6_a16(uint32_t fetchdat)
return 1;
}
tempws = ((int)((int16_t)AX)) / ((int)((int8_t)dst));
tempsrc = (int16_t) AX;
tempdst = (int8_t) dst;
tempws = tempsrc / tempdst;
if ((tempws > 127) || (tempws < -128)) {
x86_int(0);
@@ -143,7 +146,7 @@ static int opF6_a16(uint32_t fetchdat)
}
tempws = (int8_t) tempws;
tempws2 = (int8_t) ((int)((int16_t)AX)) % ((int)((int8_t)dst));
tempws2 = (int8_t) (tempsrc % tempdst);
AH = (uint8_t) tempws2;
AL = (uint8_t) tempws;
@@ -165,7 +168,7 @@ static int opF6_a16(uint32_t fetchdat)
}
static int opF6_a32(uint32_t fetchdat)
{
int tempws, tempws2 = 0;
int tempsrc, tempdst, tempws, tempws2 = 0;
uint16_t tempw, src16;
uint8_t src, dst;
@@ -236,7 +239,10 @@ static int opF6_a32(uint32_t fetchdat)
return 1;
}
tempws = ((int)((int16_t)AX)) / ((int)((int8_t)dst));
tempsrc = (int16_t) AX;
tempdst = (int8_t) dst;
tempws = tempsrc / tempdst;
if ((tempws > 127) || (tempws < -128)) {
x86_int(0);
@@ -244,7 +250,7 @@ static int opF6_a32(uint32_t fetchdat)
}
tempws = (int8_t) tempws;
tempws2 = (int8_t) ((int)((int16_t)AX)) % ((int)((int8_t)dst));
tempws2 = (int8_t) (tempsrc % tempdst);
AH = (uint8_t) tempws2;
AL = (uint8_t) tempws;
@@ -270,8 +276,7 @@ static int opF6_a32(uint32_t fetchdat)
static int opF7_w_a16(uint32_t fetchdat)
{
uint32_t templ, templ2;
uint32_t tempsrc;
int32_t tempws, tempws2 = 0;
int32_t tempsrc, tempdst, tempws, tempws2 = 0;
uint16_t src, dst;
fetch_ea_16(fetchdat);
@@ -340,8 +345,12 @@ static int opF7_w_a16(uint32_t fetchdat)
return 1;
}
tempsrc = (DX << 16) | AX;
tempws = ((int32_t)tempsrc) / ((int32_t)((int16_t)dst));
templ = (uint32_t) DX;
templ = (templ << 16) | AX;
tempsrc = (int32_t) templ;
tempdst = (int16_t) dst;
tempws = tempsrc / tempdst;
if ((tempws > 32767) || (tempws < -32768)) {
x86_int(0);
@@ -349,7 +358,7 @@ static int opF7_w_a16(uint32_t fetchdat)
}
tempws = (int16_t) tempws;
tempws2 = (int16_t) ((int32_t)tempsrc) % ((int32_t)((int16_t)dst));
tempws2 = (int16_t) (tempsrc % tempdst);
DX = (uint16_t) tempws2;
AX = (uint16_t) tempws;
@@ -369,8 +378,7 @@ static int opF7_w_a16(uint32_t fetchdat)
static int opF7_w_a32(uint32_t fetchdat)
{
uint32_t templ, templ2;
uint32_t tempsrc;
int tempws, tempws2 = 0;
int tempsrc, tempdst, tempws, tempws2 = 0;
uint16_t src, dst;
fetch_ea_32(fetchdat);
@@ -439,8 +447,12 @@ static int opF7_w_a32(uint32_t fetchdat)
return 1;
}
tempsrc = (DX << 16) | AX;
tempws = ((int32_t)tempsrc) / ((int32_t)((int16_t)dst));
templ = (uint32_t) DX;
templ = (templ << 16) | AX;
tempsrc = (int32_t) templ;
tempdst = (int16_t) dst;
tempws = tempsrc / tempdst;
if ((tempws > 32767) || (tempws < -32768)) {
x86_int(0);
@@ -448,7 +460,7 @@ static int opF7_w_a32(uint32_t fetchdat)
}
tempws = (int16_t) tempws;
tempws2 = (int16_t) ((int32_t)tempsrc) % ((int32_t)((int16_t)dst));
tempws2 = (int16_t) (tempsrc % tempdst);
DX = (uint16_t) tempws2;
AX = (uint16_t) tempws;