]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
68020/030 DIVU.W divide by zero flag fix. Same behavior as 68000.
authorToni Wilen <twilen@winuae.net>
Fri, 9 Aug 2019 19:31:48 +0000 (22:31 +0300)
committerToni Wilen <twilen@winuae.net>
Fri, 9 Aug 2019 19:31:48 +0000 (22:31 +0300)
newcpu_common.cpp

index 9784d5fd2ab677fa5940b5b3f4814ee0513f4dc0..c29c69c3ba140453ee5c329bb0c3661f8be2c6f0 100644 (file)
@@ -762,7 +762,7 @@ int getDivs68kCycles (uae_s32 dividend, uae_s16 divisor)
 /* DIV divide by zero
  *
  * 68000 Signed: NVC=0 Z=1. Unsigned: VC=0 N=(dst>>16)<0 Z=(dst>>16)==0
- * 68020 and 68030: Signed: Z=1 NVC=0. Unsigned: V=1, N<dst, Z=!N, C=0.
+ * 68020 and 68030: Signed: Z=1 NVC=0. Unsigned: V=1, N=(dst>>16)<0 Z=(dst>>16)==0, C=0.
  * 68040/68060 C=0.
  *
  */
@@ -770,13 +770,15 @@ void divbyzero_special (bool issigned, uae_s32 dst)
 {
        if (currprefs.cpu_model == 68020 || currprefs.cpu_model == 68030) {
                CLEAR_CZNV ();
-               if (issigned == false) {
-                       if (dst < 0) 
-                               SET_NFLG (1);
-                       SET_ZFLG (!GET_NFLG ());
-                       SET_VFLG (1);
+               if (issigned) {
+                       SET_ZFLG(1);
                } else {
-                       SET_ZFLG (1);
+                       uae_s16 d = dst >> 16;
+                       if (d < 0)
+                               SET_NFLG(1);
+                       else if (d == 0)
+                               SET_ZFLG(1);
+                       SET_VFLG (1);
                }
        } else if (currprefs.cpu_model >= 68040) {
                SET_CFLG (0);