ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/gencpu.c
(Generate patch)

Comparing BasiliskII/src/uae_cpu/gencpu.c (file contents):
Revision 1.24 by gbeauche, 2007-06-29T16:32:05Z vs.
Revision 1.25 by gbeauche, 2007-06-30T08:00:31Z

# Line 30 | Line 30
30  
31   #define BOOL_TYPE "int"
32  
33 + /* Define the minimal 680x0 where NV flags are not affected by xBCD instructions.  */
34 + #define xBCD_KEEPS_NV_FLAGS 4
35 +
36   static FILE *headerfile;
37   static FILE *stblfile;
38  
# Line 568 | Line 571 | static void duplicate_carry (void)
571   }
572  
573   typedef enum {
574 <    flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, flag_addx, flag_subx, flag_zn,
574 >    flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, flag_addx, flag_subx, flag_z, flag_zn,
575      flag_av, flag_sv
576   } flagtypes;
577  
# Line 622 | Line 625 | static void genflags_normal (flagtypes t
625      switch (type) {
626       case flag_logical_noclobber:
627       case flag_logical:
628 +     case flag_z:
629       case flag_zn:
630       case flag_av:
631       case flag_sv:
# Line 643 | Line 647 | static void genflags_normal (flagtypes t
647      switch (type) {
648       case flag_logical_noclobber:
649       case flag_logical:
650 +     case flag_z:
651       case flag_zn:
652          break;
653  
# Line 676 | Line 681 | static void genflags_normal (flagtypes t
681       case flag_sv:
682          printf ("\tSET_VFLG ((flgs ^ flgo) & (flgn ^ flgo));\n");
683          break;
684 +     case flag_z:
685 +        printf ("\tSET_ZFLG (GET_ZFLG & (%s == 0));\n", vstr);
686 +        break;
687       case flag_zn:
688          printf ("\tSET_ZFLG (GET_ZFLG & (%s == 0));\n", vstr);
689          printf ("\tSET_NFLG (%s < 0);\n", vstr);
# Line 921 | Line 929 | static void gen_opcode (unsigned long in
929          printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n");
930          printf ("\tSET_CFLG ((((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG ? 1 : 0)) & 0x300) > 0xFF);\n");
931          duplicate_carry ();
932 <        genflags (flag_zn, curi->size, "newv", "", "");
933 <        printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
932 >        /* Manual says bits NV are undefined though a real 68040 don't change them */
933 >        if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
934 >            if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
935 >                next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
936 >            genflags (flag_z, curi->size, "newv", "", "");
937 >        }
938 >        else {
939 >            genflags (flag_zn, curi->size, "newv", "", "");
940 >            printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
941 >        }
942          genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
943          break;
944       case i_ADD:
# Line 962 | Line 978 | static void gen_opcode (unsigned long in
978          printf ("\tif (cflg) newv += 0x60;\n");
979          printf ("\tSET_CFLG (cflg);\n");
980          duplicate_carry ();
981 <        genflags (flag_zn, curi->size, "newv", "", "");
982 <        printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
981 >        /* Manual says bits NV are undefined though a real 68040 don't change them */
982 >        if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
983 >            if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
984 >                next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
985 >            genflags (flag_z, curi->size, "newv", "", "");
986 >        }
987 >        else {
988 >            genflags (flag_zn, curi->size, "newv", "", "");
989 >            printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
990 >        }
991          genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
992          break;
993       case i_NEG:
# Line 993 | Line 1017 | static void gen_opcode (unsigned long in
1017          printf ("\tif (cflg) newv -= 0x60;\n");
1018          printf ("\tSET_CFLG (cflg);\n");
1019          duplicate_carry();
1020 <        genflags (flag_zn, curi->size, "newv", "", "");
1020 >        /* Manual says bits NV are undefined though a real 68040 don't change them */
1021 >        if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
1022 >            if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
1023 >                next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
1024 >            genflags (flag_z, curi->size, "newv", "", "");
1025 >        }
1026 >        else {
1027 >            genflags (flag_zn, curi->size, "newv", "", "");
1028 >        }
1029          genastore ("newv", curi->smode, "srcreg", curi->size, "src");
1030          break;
1031       case i_CLR:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines