diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 9c887db29..61978af3b 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -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; diff --git a/src/cpu/x86_ops_misc.h b/src/cpu/x86_ops_misc.h index 7448007fb..517f22d72 100644 --- a/src/cpu/x86_ops_misc.h +++ b/src/cpu/x86_ops_misc.h @@ -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; diff --git a/src/mouse_bus.c b/src/mouse_bus.c index ec72b4187..cbe4ba40a 100644 --- a/src/mouse_bus.c +++ b/src/mouse_bus.c @@ -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, * @@ -584,6 +584,7 @@ bm_close(void *priv) bm_read, NULL, NULL, bm_write, NULL, NULL, dev); free(dev); + dev = NULL; } diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index 312038883..c5e9af72d 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -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, */ @@ -261,6 +261,7 @@ ps2_close(void *priv) keyboard_at_set_mouse(NULL, NULL); free(dev); + dev = NULL; } diff --git a/src/mouse_serial.c b/src/mouse_serial.c index c723d3ae0..5907898ed 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -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, */ @@ -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; }