Fixed the overflow checks for all IDIV instructions for 286+ CPU's;

Fixed the mouse close functions.
This commit is contained in:
OBattler
2017-12-14 01:35:04 +01:00
parent 044559f4e9
commit 8c38b94594
5 changed files with 12 additions and 17 deletions

View File

@@ -477,7 +477,7 @@ int idivl(int32_t val)
rem=num%val;
quo32=(int32_t)(quo&0xFFFFFFFF);
if (quo!=(int64_t)quo32)
if ((quo > 0x000000007FFFFFFFLL) || (quo < 0xFFFFFFFF80000000LL))
{
divexcp();
return 1;

View File

@@ -67,7 +67,6 @@ static int opF6_a16(uint32_t fetchdat)
int tempws, tempws2 = 0;
uint16_t tempw, src16;
uint8_t src, dst;
int8_t temps;
fetch_ea_16(fetchdat);
dst = geteab(); if (cpu_state.abrt) return 1;
@@ -133,8 +132,7 @@ static int opF6_a16(uint32_t fetchdat)
case 0x38: /*IDIV AL,b*/
tempws = (int)(int16_t)AX;
if (dst != 0) tempws2 = tempws / (int)((int8_t)dst);
temps = tempws2 & 0xff;
if (dst && ((int)temps == tempws2))
if (dst && ((tempws2 > 0x0000007F) || (tempws2 < 0xFFFFFF80)))
{
AH = (tempws % (int)((int8_t)dst)) & 0xff;
AL = tempws2 & 0xff;
@@ -164,7 +162,6 @@ static int opF6_a32(uint32_t fetchdat)
int tempws, tempws2 = 0;
uint16_t tempw, src16;
uint8_t src, dst;
int8_t temps;
fetch_ea_32(fetchdat);
dst = geteab(); if (cpu_state.abrt) return 1;
@@ -230,8 +227,7 @@ static int opF6_a32(uint32_t fetchdat)
case 0x38: /*IDIV AL,b*/
tempws = (int)(int16_t)AX;
if (dst != 0) tempws2 = tempws / (int)((int8_t)dst);
temps = tempws2 & 0xff;
if (dst && ((int)temps == tempws2))
if (dst && ((tempws2 > 0x0000007F) || (tempws2 < 0xFFFFFF80)))
{
AH = (tempws % (int)((int8_t)dst)) & 0xff;
AL = tempws2 & 0xff;
@@ -263,7 +259,6 @@ static int opF7_w_a16(uint32_t fetchdat)
{
uint32_t templ, templ2;
int tempws, tempws2 = 0;
int16_t temps16;
uint16_t src, dst;
fetch_ea_16(fetchdat);
@@ -329,8 +324,7 @@ static int opF7_w_a16(uint32_t fetchdat)
case 0x38: /*IDIV AX,w*/
tempws = (int)((DX << 16)|AX);
if (dst) tempws2 = tempws / (int)((int16_t)dst);
temps16 = tempws2 & 0xffff;
if ((dst != 0) && ((int)temps16 == tempws2))
if ((dst != 0) && ((tempws2 > 0x00007FFF) || (tempws2 < 0xFFFF8000)))
{
DX = tempws % (int)((int16_t)dst);
AX = tempws2 & 0xffff;
@@ -355,7 +349,6 @@ static int opF7_w_a32(uint32_t fetchdat)
{
uint32_t templ, templ2;
int tempws, tempws2 = 0;
int16_t temps16;
uint16_t src, dst;
fetch_ea_32(fetchdat);
@@ -421,8 +414,7 @@ static int opF7_w_a32(uint32_t fetchdat)
case 0x38: /*IDIV AX,w*/
tempws = (int)((DX << 16)|AX);
if (dst) tempws2 = tempws / (int)((int16_t)dst);
temps16 = tempws2 & 0xffff;
if ((dst != 0) && ((int)temps16 == tempws2))
if ((dst != 0) && ((tempws2 > 0x00007FFF) || (tempws2 < 0xFFFF8000)))
{
DX = tempws % (int)((int16_t)dst);
AX = tempws2 & 0xffff;

View File

@@ -53,7 +53,7 @@
* only the Logitech part is considered to
* be OK.
*
* Version: @(#)mouse_bus.c 1.0.27 2017/12/09
* Version: @(#)mouse_bus.c 1.0.28 2017/12/14
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -584,6 +584,7 @@ bm_close(void *priv)
bm_read, NULL, NULL, bm_write, NULL, NULL, dev);
free(dev);
dev = NULL;
}

View File

@@ -8,7 +8,7 @@
*
* Implementation of PS/2 series Mouse devices.
*
* Version: @(#)mouse_ps2.c 1.0.3 2017/12/09
* Version: @(#)mouse_ps2.c 1.0.4 2017/12/13
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
*/
@@ -261,6 +261,7 @@ ps2_close(void *priv)
keyboard_at_set_mouse(NULL, NULL);
free(dev);
dev = NULL;
}

View File

@@ -10,7 +10,7 @@
*
* TODO: Add the Genius Serial Mouse.
*
* Version: @(#)mouse_serial.c 1.0.16 2017/12/09
* Version: @(#)mouse_serial.c 1.0.17 2017/12/13
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*/
@@ -199,12 +199,13 @@ sermouse_close(void *priv)
mouse_t *dev = (mouse_t *)priv;
/* Detach serial port from the mouse. */
if (dev->serial != NULL) {
if ((dev != NULL) && (dev->serial != NULL)) {
dev->serial->rcr_callback = NULL;
dev->serial->rcr_callback_p = NULL;
}
free(dev);
dev = NULL;
}