Skip to contentSkip to conversation

m68k: add partial Motorola 680x0 support

PATCH In review Laurent Vivier 5 participants 26 messages May 29, 2009 – Sep 21, 2009

lore
Share & tools
lore
#0 lore raw

cover m68k: add partial Motorola 680x0 support

This series of patches is a port to Qemu 0.10 of Andreas Schwab M68K patch to support Motorola 680x0 CPU family.

It has been tested with some commands from a debian m68k lenny disk.

Commands like "uname", "date", "ls", "more", "grep" work well.

[PATCH 01/17] m68k: Replace gen_im32() by tcg_const_i32() [PATCH 02/17] m68k: add tcg_gen_debug_insn_start()
[PATCH 03/17] m68k: define m680x0 CPUs and features
[PATCH 04/17] m68k: add missing accessing modes for some instructions. [PATCH 05/17] m68k: add Motorola 680x0 family common instructions. [PATCH 06/17] m68k: add Scc instruction with memory operand. [PATCH 07/17] m68k: add DBcc instruction.
[PATCH 08/17] m68k: modify movem instruction to manage word [PATCH 09/17] m68k: add 64bit divide.
[PATCH 10/17] m68k: add 32bit and 64bit multiply
[PATCH 11/17] m68k: add word data size for suba/adda
[PATCH 12/17] m68k: add fpu
[PATCH 13/17] m68k: add "byte", "word" and memory shift
[PATCH 14/17] m68k: add "byte", "word" and memory rotate. [PATCH 15/17] m68k: add bitfield_mem, bitfield_reg
[PATCH 16/17] m68k: add variable offset/width to bitfield_reg/bitfield_mem [PATCH 17/17] m68k: add cas

#1 lore raw

PATCH 1/17 m68k: Replace gen_im32() by tcg_const_i32()

---
 target-m68k/translate.c |   43 ++++++++++++++++++++-----------------------
 1 files changed, 20 insertions(+), 23 deletions(-)
target-m68k/translate.c +20 -23
index 422f0a4..521891f 100644
@@ -172,9 +172,6 @@ typedef void (*disas_proc)(DisasContext *, uint16_t);
   static void disas_##name (DisasContext *s, uint16_t insn)
 #endif
 
-/* FIXME: Remove this.  */
-#define gen_im32(val) tcg_const_i32(val)
-
 /* Generate a load from the specified address.  Narrow values are
    sign extended to full register width.  */
 static inline TCGv gen_load(DisasContext * s, int opsize, TCGv addr, int sign)
@@ -340,7 +337,7 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
         if ((ext & 0x80) == 0) {
             /* base not suppressed */
             if (IS_NULL_QREG(base)) {
-                base = gen_im32(offset + bd);
+                base = tcg_const_i32(offset + bd);
                 bd = 0;
             }
             if (!IS_NULL_QREG(add)) {
@@ -356,7 +353,7 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
                 add = tmp;
             }
         } else {
-            add = gen_im32(bd);
+            add = tcg_const_i32(bd);
         }
         if ((ext & 3) != 0) {
             /* memory indirect */
@@ -537,16 +534,16 @@ static TCGv gen_lea(DisasContext *s, uint16_t insn, int opsize)
         case 0: /* Absolute short.  */
             offset = ldsw_code(s->pc);
             s->pc += 2;
-            return gen_im32(offset);
+            return tcg_const_i32(offset);
         case 1: /* Absolute long.  */
             offset = read_im32(s);
-            return gen_im32(offset);
+            return tcg_const_i32(offset);
         case 2: /* pc displacement  */
             tmp = tcg_temp_new();
             offset = s->pc;
             offset += ldsw_code(s->pc);
             s->pc += 2;
-            return gen_im32(offset);
+            return tcg_const_i32(offset);
         case 3: /* pc index+displacement.  */
             return gen_lea_indexed(s, opsize, NULL_QREG);
         case 4: /* Immediate.  */
@@ -1211,16 +1208,16 @@ DISAS_INSN(arith_im)
         break;
     case 2: /* subi */
         tcg_gen_mov_i32(dest, src1);
-        gen_helper_xflag_lt(QREG_CC_X, dest, gen_im32(im));
+        gen_helper_xflag_lt(QREG_CC_X, dest, tcg_const_i32(im));
         tcg_gen_subi_i32(dest, dest, im);
-        gen_update_cc_add(dest, gen_im32(im));
+        gen_update_cc_add(dest, tcg_const_i32(im));
         s->cc_op = CC_OP_SUB;
         break;
     case 3: /* addi */
         tcg_gen_mov_i32(dest, src1);
         tcg_gen_addi_i32(dest, dest, im);
-        gen_update_cc_add(dest, gen_im32(im));
-        gen_helper_xflag_lt(QREG_CC_X, dest, gen_im32(im));
+        gen_update_cc_add(dest, tcg_const_i32(im));
+        gen_helper_xflag_lt(QREG_CC_X, dest, tcg_const_i32(im));
         s->cc_op = CC_OP_ADD;
         break;
     case 5: /* eori */
@@ -1230,7 +1227,7 @@ DISAS_INSN(arith_im)
     case 6: /* cmpi */
         tcg_gen_mov_i32(dest, src1);
         tcg_gen_subi_i32(dest, dest, im);
-        gen_update_cc_add(dest, gen_im32(im));
+        gen_update_cc_add(dest, tcg_const_i32(im));
         s->cc_op = CC_OP_SUB;
         break;
     default:
@@ -1326,8 +1323,8 @@ DISAS_INSN(clr)
     default:
         abort();
     }
-    DEST_EA(insn, opsize, gen_im32(0), NULL);
-    gen_logic_cc(s, gen_im32(0));
+    DEST_EA(insn, opsize, tcg_const_i32(0), NULL);
+    gen_logic_cc(s, tcg_const_i32(0));
 }
 
 static TCGv gen_get_ccr(DisasContext *s)
@@ -1591,7 +1588,7 @@ DISAS_INSN(jump)
     }
     if ((insn & 0x40) == 0) {
         /* jsr */
-        gen_push(s, gen_im32(s->pc));
+        gen_push(s, tcg_const_i32(s->pc));
     }
     gen_jmp(s, tmp);
 }
@@ -1619,7 +1616,7 @@ DISAS_INSN(addsubq)
             tcg_gen_addi_i32(dest, dest, val);
         }
     } else {
-        src2 = gen_im32(val);
+        src2 = tcg_const_i32(val);
         if (insn & 0x0100) {
             gen_helper_xflag_lt(QREG_CC_X, dest, src2);
             tcg_gen_subi_i32(dest, dest, val);
@@ -1668,7 +1665,7 @@ DISAS_INSN(branch)
     }
     if (op == 1) {
         /* bsr */
-        gen_push(s, gen_im32(s->pc));
+        gen_push(s, tcg_const_i32(s->pc));
     }
     gen_flush_cc_op(s);
     if (op > 1) {
@@ -1759,7 +1756,7 @@ DISAS_INSN(mov3q)
     val = (insn >> 9) & 7;
     if (val == 0)
         val = -1;
-    src = gen_im32(val);
+    src = tcg_const_i32(val);
     gen_logic_cc(s, src);
     DEST_EA(insn, OS_LONG, src, NULL);
 }
@@ -1885,7 +1882,7 @@ DISAS_INSN(shift_im)
     tmp = (insn >> 9) & 7;
     if (tmp == 0)
         tmp = 8;
-    shift = gen_im32(tmp);
+    shift = tcg_const_i32(tmp);
     /* No need to flush flags becuse we know we will set C flag.  */
     if (insn & 0x100) {
         gen_helper_shl_cc(reg, cpu_env, reg, shift);
@@ -2193,7 +2190,7 @@ DISAS_INSN(fpu)
         switch ((ext >> 10) & 7) {
         case 4: /* FPCR */
             /* Not implemented.  Always return zero.  */
-            tmp32 = gen_im32(0);
+            tmp32 = tcg_const_i32(0);
             break;
         case 1: /* FPIAR */
         case 2: /* FPSR */
@@ -2594,7 +2591,7 @@ DISAS_INSN(mac)
         /* Skip the accumulate if the value is already saturated.  */
         l1 = gen_new_label();
         tmp = tcg_temp_new();
-        gen_op_and32(tmp, QREG_MACSR, gen_im32(MACSR_PAV0 << acc));
+        gen_op_and32(tmp, QREG_MACSR, tcg_const_i32(MACSR_PAV0 << acc));
         gen_op_jmp_nz32(tmp, l1);
     }
 #endif
@@ -2628,7 +2625,7 @@ DISAS_INSN(mac)
             /* Skip the accumulate if the value is already saturated.  */
             l1 = gen_new_label();
             tmp = tcg_temp_new();
-            gen_op_and32(tmp, QREG_MACSR, gen_im32(MACSR_PAV0 << acc));
+            gen_op_and32(tmp, QREG_MACSR, tcg_const_i32(MACSR_PAV0 << acc));
             gen_op_jmp_nz32(tmp, l1);
         }
 #endif
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/17 m68k: add tcg_gen_debug_insn_start()

This patch add debug info by writing the PC of the corresponing CPU instruction of an TCG opcode.

---
 target-m68k/translate.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
target-m68k/translate.c +3 -0
index 521891f..dc34a2a 100644
@@ -2950,6 +2950,9 @@ static void disas_m68k_insn(CPUState * env, DisasContext *s)
 {
     uint16_t insn;
 
+    if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)))
+        tcg_gen_debug_insn_start(s->pc);
+
     insn = lduw_code(s->pc);
     s->pc += 2;
 
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/17 m68k: define m680x0 CPUs and features

This patch defines four new Motorola 680x0 family CPUs:

- M68K_CPUID_M68000,
- M68K_CPUID_M68020,
- M68K_CPUID_M68040,
- M68K_CPUID_M68060

And six new features:

- M68K_FEATURE_SCALED_INDEX, scaled address index register
- M68K_FEATURE_LONG_MULDIV, 32bit multiply/divide
- M68K_FEATURE_QUAD_MULDIV, 64bit multiply/divide
- M68K_FEATURE_BCCL, long conditional branches
- M68K_FEATURE_BITFIELD, bit field instructions
- M68K_FEATURE_FPU, FPU instructions

Following patches implement them...

---
 target-m68k/cpu.h    |   13 ++++++++++---
 target-m68k/helper.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 3 deletions(-)
target-m68k/cpu.h +10 -3
index feffb6b..eb18e9e 100644
@@ -181,6 +181,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr);
    ISA revisions mentioned.  */
 
 enum m68k_features {
+    M68K_FEATURE_M68000,
     M68K_FEATURE_CF_ISA_A,
     M68K_FEATURE_CF_ISA_B, /* (ISA B or C).  */
     M68K_FEATURE_CF_ISA_APLUSC, /* BIT/BITREV, FF1, STRLDSR (ISA A+ or C).  */
@@ -191,7 +192,13 @@ enum m68k_features {
     M68K_FEATURE_CF_EMAC_B, /* Revision B EMAC (dual accumulate).  */
     M68K_FEATURE_USP, /* User Stack Pointer.  (ISA A+, B or C).  */
     M68K_FEATURE_EXT_FULL, /* 68020+ full extension word.  */
-    M68K_FEATURE_WORD_INDEX /* word sized address index registers.  */
+    M68K_FEATURE_WORD_INDEX, /* word sized address index registers.  */
+    M68K_FEATURE_SCALED_INDEX, /* scaled address index registers.  */
+    M68K_FEATURE_LONG_MULDIV,	/* 32 bit multiply/divide. */
+    M68K_FEATURE_QUAD_MULDIV,	/* 64 bit multiply/divide. */
+    M68K_FEATURE_BCCL,		/* Long conditional branches.  */
+    M68K_FEATURE_BITFIELD,	/* Bit field insns.  */
+    M68K_FEATURE_FPU
 };
 
 static inline int m68k_feature(CPUM68KState *env, int feature)
@@ -204,8 +211,8 @@ void m68k_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
 void register_m68k_insns (CPUM68KState *env);
 
 #ifdef CONFIG_USER_ONLY
-/* Linux uses 8k pages.  */
-#define TARGET_PAGE_BITS 13
+/* Linux uses 4k pages.  */
+#define TARGET_PAGE_BITS 12
 #else
 /* Smallest TLB entry size is 1k.  */
 #define TARGET_PAGE_BITS 10
target-m68k/helper.c +33 -0
index af9ce22..a22dc97 100644
@@ -33,6 +33,10 @@
 #define SIGNBIT (1u << 31)
 
 enum m68k_cpuid {
+    M68K_CPUID_M68000,
+    M68K_CPUID_M68020,
+    M68K_CPUID_M68040,
+    M68K_CPUID_M68060,
     M68K_CPUID_M5206,
     M68K_CPUID_M5208,
     M68K_CPUID_CFV4E,
@@ -47,6 +51,10 @@ struct m68k_def_t {
 };
 
 static m68k_def_t m68k_cpu_defs[] = {
+    {"m68000", M68K_CPUID_M68000},
+    {"m68020", M68K_CPUID_M68020},
+    {"m68040", M68K_CPUID_M68040},
+    {"m68060", M68K_CPUID_M68060},
     {"m5206", M68K_CPUID_M5206},
     {"m5208", M68K_CPUID_M5208},
     {"cfv4e", M68K_CPUID_CFV4E},
@@ -107,12 +115,30 @@ static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
         return -1;
 
     switch (def->id) {
+    case M68K_CPUID_M68020:
+    case M68K_CPUID_M68040:
+        m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
+    case M68K_CPUID_M68060:
+        m68k_set_feature(env, M68K_FEATURE_BRAL);
+        m68k_set_feature(env, M68K_FEATURE_BCCL);
+        m68k_set_feature(env, M68K_FEATURE_BITFIELD);
+        m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
+        m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
+        m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
+        m68k_set_feature(env, M68K_FEATURE_FPU);
+    case M68K_CPUID_M68000:
+        m68k_set_feature(env, M68K_FEATURE_M68000);
+        m68k_set_feature(env, M68K_FEATURE_USP);
+        m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
+        break;
     case M68K_CPUID_M5206:
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
+        m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
         break;
     case M68K_CPUID_M5208:
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_APLUSC);
+        m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
         m68k_set_feature(env, M68K_FEATURE_BRAL);
         m68k_set_feature(env, M68K_FEATURE_CF_EMAC);
         m68k_set_feature(env, M68K_FEATURE_USP);
@@ -120,16 +146,19 @@ static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
     case M68K_CPUID_CFV4E:
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_B);
+        m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
         m68k_set_feature(env, M68K_FEATURE_BRAL);
         m68k_set_feature(env, M68K_FEATURE_CF_FPU);
         m68k_set_feature(env, M68K_FEATURE_CF_EMAC);
         m68k_set_feature(env, M68K_FEATURE_USP);
         break;
     case M68K_CPUID_ANY:
+        m68k_set_feature(env, M68K_FEATURE_M68000);
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_B);
         m68k_set_feature(env, M68K_FEATURE_CF_ISA_APLUSC);
         m68k_set_feature(env, M68K_FEATURE_BRAL);
+        m68k_set_feature(env, M68K_FEATURE_BCCL);
         m68k_set_feature(env, M68K_FEATURE_CF_FPU);
         /* MAC and EMAC are mututally exclusive, so pick EMAC.
            It's mostly backwards compatible.  */
@@ -137,7 +166,11 @@ static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
         m68k_set_feature(env, M68K_FEATURE_CF_EMAC_B);
         m68k_set_feature(env, M68K_FEATURE_USP);
         m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
+        m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
         m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
+        m68k_set_feature(env, M68K_FEATURE_BITFIELD);
+        m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
+        m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
         break;
     }
 
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH 4/17 m68k: add missing accessing modes for some instructions.

This patch modifies following instructions to allow them to manage data size other than "long", by adding "byte" and "word" data size: "addsub", "arith_im", "addsubq", "or", "eor", "and".

This patch modifies following instructions to use EA to access data:
"neg", "not".

---
 target-m68k/cpu.h       |   10 ++-
 target-m68k/helper.c    |   74 ++++++++++++-----
 target-m68k/translate.c |  202 +++++++++++++++++++++++++++--------------------
 3 files changed, 177 insertions(+), 109 deletions(-)
target-m68k/cpu.h +8 -2
index eb18e9e..240d75f 100644
@@ -131,11 +131,17 @@ enum {
     CC_OP_DYNAMIC, /* Use env->cc_op  */
     CC_OP_FLAGS, /* CC_DEST = CVZN, CC_SRC = unused */
     CC_OP_LOGIC, /* CC_DEST = result, CC_SRC = unused */
+    CC_OP_ADDB,   /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDW,   /* CC_DEST = result, CC_SRC = source */
     CC_OP_ADD,   /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBB,   /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBW,   /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUB,   /* CC_DEST = result, CC_SRC = source */
-    CC_OP_CMPB,  /* CC_DEST = result, CC_SRC = source */
-    CC_OP_CMPW,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDXB,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDXW,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_ADDX,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBXB,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBXW,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUBX,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_SHIFT, /* CC_DEST = result, CC_SRC = carry */
 };
target-m68k/helper.c +52 -22

96 lines not on this page · raw message

target-m68k/translate.c +117 -85

371 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#5 lore raw

PATCH 5/17 m68k: add Motorola 680x0 family common instructions.

This patch declares existing ISA instructions belonging to previously defined 680x0 familty new features:

- modify gen_lea_indexed() to manage scaled index,

- declare M68000 instructions: arith_im, bitop_reg, arith_im, bitop_im, move, negx, move_from_sr, lea, clr, neg, move_to_ccr, not, pea, swap, ext, tas, tst, illegal, trap, link, unlk, nop, stop, rte, rts, jump, addsubq, scc, branch, moveq, or, divw, addsub, subx, cmp, cmpa, eor, and, mulw, addx, shift_im, shift_reg.

- declare FPU instructions: fbcc, frestore, fsave,

- declare long branch instructions: branch.

---
 target-m68k/translate.c |   89 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 85 insertions(+), 4 deletions(-)
target-m68k/translate.c +85 -4
index 1bf7169..cd46651 100644
@@ -327,6 +327,9 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
     if ((ext & 0x800) == 0 && !m68k_feature(s->env, M68K_FEATURE_WORD_INDEX))
         return NULL_QREG;
 
+    if (!m68k_feature(s->env, M68K_FEATURE_SCALED_INDEX))
+        ext &= ~(3 << 9);
+
     if (ext & 0x100) {
         /* full extension word format */
         if (!m68k_feature(s->env, M68K_FEATURE_EXT_FULL))
@@ -335,7 +338,7 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
         if ((ext & 0x30) > 0x10) {
             /* base displacement */
             if ((ext & 0x30) == 0x20) {
-                bd = (int16_t)lduw_code(s->pc);
+                bd = ldsw_code(s->pc);
                 s->pc += 2;
             } else {
                 bd = read_im32(s);
@@ -384,7 +387,7 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
             if ((ext & 3) > 1) {
                 /* outer displacement */
                 if ((ext & 3) == 2) {
-                    od = (int16_t)lduw_code(s->pc);
+                    od = ldsw_code(s->pc);
                     s->pc += 2;
                 } else {
                     od = read_im32(s);
@@ -2859,85 +2862,149 @@ void register_m68k_insns (CPUM68KState *env)
         register_opcode(disas_##name, 0x##opcode, 0x##mask); \
     } while(0)
     INSN(undef,     0000, 0000, CF_ISA_A);
+    INSN(undef,     0000, 0000, M68000);
     INSN(arith_im,  0080, fff8, CF_ISA_A);
+    INSN(arith_im,  0000, ff00, M68000);
+    INSN(undef,     00c0, ffc0, M68000);
     INSN(bitrev,    00c0, fff8, CF_ISA_APLUSC);
     INSN(bitop_reg, 0100, f1c0, CF_ISA_A);
+    INSN(bitop_reg, 0100, f1c0, M68000);
     INSN(bitop_reg, 0140, f1c0, CF_ISA_A);
+    INSN(bitop_reg, 0140, f1c0, M68000);
     INSN(bitop_reg, 0180, f1c0, CF_ISA_A);
+    INSN(bitop_reg, 0180, f1c0, M68000);
     INSN(bitop_reg, 01c0, f1c0, CF_ISA_A);
+    INSN(bitop_reg, 01c0, f1c0, M68000);
     INSN(arith_im,  0280, fff8, CF_ISA_A);
+    INSN(arith_im,  0200, ff00, M68000);
+    INSN(undef,     02c0, ffc0, M68000);
     INSN(byterev,   02c0, fff8, CF_ISA_APLUSC);
     INSN(arith_im,  0480, fff8, CF_ISA_A);
+    INSN(arith_im,  0400, ff00, M68000);
+    INSN(undef,     04c0, ffc0, M68000);
+    INSN(arith_im,  0600, ff00, M68000);
+    INSN(undef,     06c0, ffc0, M68000);
     INSN(ff1,       04c0, fff8, CF_ISA_APLUSC);
     INSN(arith_im,  0680, fff8, CF_ISA_A);
     INSN(bitop_im,  0800, ffc0, CF_ISA_A);
+    INSN(bitop_im,  0800, ffc0, M68000);
     INSN(bitop_im,  0840, ffc0, CF_ISA_A);
+    INSN(bitop_im,  0840, ffc0, M68000);
     INSN(bitop_im,  0880, ffc0, CF_ISA_A);
+    INSN(bitop_im,  0880, ffc0, M68000);
     INSN(bitop_im,  08c0, ffc0, CF_ISA_A);
+    INSN(bitop_im,  08c0, ffc0, M68000);
     INSN(arith_im,  0a80, fff8, CF_ISA_A);
+    INSN(arith_im,  0a00, ff00, M68000);
+    INSN(undef,     0ac0, ffc0, M68000);
     INSN(arith_im,  0c00, ff38, CF_ISA_A);
+    INSN(arith_im,  0c00, ff00, M68000);
+    INSN(undef,     0cc0, ffc0, M68000);
     INSN(move,      1000, f000, CF_ISA_A);
+    INSN(move,      1000, f000, M68000);
     INSN(move,      2000, f000, CF_ISA_A);
+    INSN(move,      2000, f000, M68000);
     INSN(move,      3000, f000, CF_ISA_A);
+    INSN(move,      3000, f000, M68000);
     INSN(strldsr,   40e7, ffff, CF_ISA_APLUSC);
     INSN(negx,      4080, fff8, CF_ISA_A);
+    INSN(negx,      4080, fff8, M68000);
+    INSN(undef,     40c0, ffc0, M68000);
     INSN(move_from_sr, 40c0, fff8, CF_ISA_A);
+    INSN(move_from_sr, 40c0, fff8, M68000);
     INSN(lea,       41c0, f1c0, CF_ISA_A);
+    INSN(lea,       41c0, f1c0, M68000);
     INSN(clr,       4200, ff00, CF_ISA_A);
+    INSN(clr,       4200, ff00, M68000);
     INSN(undef,     42c0, ffc0, CF_ISA_A);
+    INSN(undef,     42c0, ffc0, M68000);
     INSN(move_from_ccr, 42c0, fff8, CF_ISA_A);
     INSN(neg,       4480, fff8, CF_ISA_A);
+    INSN(neg,       4400, ff00, M68000);
+    INSN(undef,     44c0, ffc0, M68000);
     INSN(move_to_ccr, 44c0, ffc0, CF_ISA_A);
+    INSN(move_to_ccr, 44c0, ffc0, M68000);
     INSN(not,       4680, fff8, CF_ISA_A);
+    INSN(not,       4600, ff00, M68000);
+    INSN(undef,     46c0, ffc0, M68000);
     INSN(move_to_sr, 46c0, ffc0, CF_ISA_A);
     INSN(pea,       4840, ffc0, CF_ISA_A);
+    INSN(pea,       4840, ffc0, M68000);
     INSN(swap,      4840, fff8, CF_ISA_A);
+    INSN(swap,      4840, fff8, M68000);
     INSN(movem,     48c0, fbc0, CF_ISA_A);
     INSN(ext,       4880, fff8, CF_ISA_A);
+    INSN(ext,       4880, fff8, M68000);
     INSN(ext,       48c0, fff8, CF_ISA_A);
+    INSN(ext,       48c0, fff8, M68000);
     INSN(ext,       49c0, fff8, CF_ISA_A);
+    INSN(ext,       49c0, fff8, M68000);
     INSN(tst,       4a00, ff00, CF_ISA_A);
+    INSN(tst,       4a00, ff00, M68000);
     INSN(tas,       4ac0, ffc0, CF_ISA_B);
+    INSN(tas,       4ac0, ffc0, M68000);
     INSN(halt,      4ac8, ffff, CF_ISA_A);
     INSN(pulse,     4acc, ffff, CF_ISA_A);
     INSN(illegal,   4afc, ffff, CF_ISA_A);
+    INSN(illegal,   4afc, ffff, M68000);
     INSN(mull,      4c00, ffc0, CF_ISA_A);
     INSN(divl,      4c40, ffc0, CF_ISA_A);
     INSN(sats,      4c80, fff8, CF_ISA_B);
     INSN(trap,      4e40, fff0, CF_ISA_A);
+    INSN(trap,      4e40, fff0, M68000);
     INSN(link,      4e50, fff8, CF_ISA_A);
+    INSN(link,      4e50, fff8, M68000);
     INSN(unlk,      4e58, fff8, CF_ISA_A);
+    INSN(unlk,      4e58, fff8, M68000);
     INSN(move_to_usp, 4e60, fff8, USP);
     INSN(move_from_usp, 4e68, fff8, USP);
     INSN(nop,       4e71, ffff, CF_ISA_A);
+    INSN(nop,       4e71, ffff, M68000);
     INSN(stop,      4e72, ffff, CF_ISA_A);
+    INSN(stop,      4e72, ffff, M68000);
     INSN(rte,       4e73, ffff, CF_ISA_A);
+    INSN(rte,       4e73, ffff, M68000);
     INSN(rts,       4e75, ffff, CF_ISA_A);
+    INSN(rts,       4e75, ffff, M68000);
     INSN(movec,     4e7b, ffff, CF_ISA_A);
     INSN(jump,      4e80, ffc0, CF_ISA_A);
+    INSN(jump,      4e80, ffc0, M68000);
     INSN(jump,      4ec0, ffc0, CF_ISA_A);
-    INSN(addsubq,   5180, f1c0, CF_ISA_A);
+    INSN(jump,      4ec0, ffc0, M68000);
+    INSN(addsubq,   5080, f0c0, CF_ISA_A);
+    INSN(addsubq,   5000, f080, M68000);
+    INSN(addsubq,   5080, f0c0, M68000);
     INSN(scc,       50c0, f0f8, CF_ISA_A);
-    INSN(addsubq,   5080, f1c0, CF_ISA_A);
+    INSN(scc,       50c0, f0f8, M68000);
     INSN(tpf,       51f8, fff8, CF_ISA_A);
 
     /* Branch instructions.  */
     INSN(branch,    6000, f000, CF_ISA_A);
+    INSN(branch,    6000, f000, M68000);
     /* Disable long branch instructions, then add back the ones we want.  */
     INSN(undef,     60ff, f0ff, CF_ISA_A); /* All long branches.  */
+    INSN(undef,     60ff, f0ff, M68000); /* All long branches.  */
     INSN(branch,    60ff, f0ff, CF_ISA_B);
     INSN(undef,     60ff, ffff, CF_ISA_B); /* bra.l */
     INSN(branch,    60ff, ffff, BRAL);
+    INSN(branch,    60ff, f0ff, BCCL);
 
     INSN(moveq,     7000, f100, CF_ISA_A);
+    INSN(moveq,     7000, f100, M68000);
     INSN(mvzs,      7100, f100, CF_ISA_B);
     INSN(or,        8000, f000, CF_ISA_A);
+    INSN(or,        8000, f000, M68000);
     INSN(divw,      80c0, f0c0, CF_ISA_A);
+    INSN(divw,      80c0, f0c0, M68000);
     INSN(addsub,    9000, f000, CF_ISA_A);
+    INSN(addsub,    9000, f000, M68000);
+    INSN(undef,     90c0, f0c0, CF_ISA_A);
     INSN(subx,      9180, f1f8, CF_ISA_A);
+    INSN(subx,      9100, f138, M68000);
     INSN(suba,      91c0, f1c0, CF_ISA_A);
 
     INSN(undef_mac, a000, f000, CF_ISA_A);
+    INSN(undef_mac, a000, f000, M68000);
     INSN(mac,       a000, f100, CF_EMAC);
     INSN(from_mac,  a180, f9b0, CF_EMAC);
     INSN(move_mac,  a110, f9fc, CF_EMAC);
@@ -2956,19 +3023,33 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(cmpa,      b0c0, f1c0, CF_ISA_B); /* cmpa.w */
     INSN(cmp,       b080, f1c0, CF_ISA_A);
     INSN(cmpa,      b1c0, f1c0, CF_ISA_A);
+    INSN(cmp,       b000, f100, M68000);
+    INSN(cmpa,      b0c0, f0c0, M68000);
     INSN(eor,       b180, f1c0, CF_ISA_A);
+    INSN(eor,       b180, f1c0, M68000);
     INSN(and,       c000, f000, CF_ISA_A);
+    INSN(and,       c000, f000, M68000);
     INSN(mulw,      c0c0, f0c0, CF_ISA_A);
+    INSN(mulw,      c0c0, f0c0, M68000);
     INSN(addsub,    d000, f000, CF_ISA_A);
+    INSN(addsub,    d000, f000, M68000);
+    INSN(undef,     d0c0, f0c0, CF_ISA_A);
     INSN(addx,      d180, f1f8, CF_ISA_A);
+    INSN(addx,      d100, f138, M68000);
     INSN(adda,      d1c0, f1c0, CF_ISA_A);
     INSN(shift_im,  e080, f0f0, CF_ISA_A);
     INSN(shift_reg, e0a0, f0f0, CF_ISA_A);
+    INSN(shift_im,    e080, f0f0, M68000);
+    INSN(shift_reg,   e0a0, f0f0, M68000);
     INSN(undef_fpu, f000, f000, CF_ISA_A);
+    INSN(undef_fpu, f000, f000, M68000);
     INSN(fpu,       f200, ffc0, CF_FPU);
     INSN(fbcc,      f280, ffc0, CF_FPU);
     INSN(frestore,  f340, ffc0, CF_FPU);
     INSN(fsave,     f340, ffc0, CF_FPU);
+    INSN(fbcc,      f280, ffc0, FPU);
+    INSN(frestore,  f340, ffc0, FPU);
+    INSN(fsave,     f340, ffc0, FPU);
     INSN(intouch,   f340, ffc0, CF_ISA_A);
     INSN(cpushl,    f428, ff38, CF_ISA_A);
     INSN(wddata,    fb00, ff00, CF_ISA_A);
Signature · 1 line
1.5.6.5
#6 lore raw

PATCH 6/17 m68k: add Scc instruction with memory operand.

This patch defines Scc instruction for M68000 feature accessing destination operand using an effective address (existing Scc instruction manages only data registers).

---
 target-m68k/translate.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
target-m68k/translate.c +18 -0
index cd46651..d08e1c8 100644
@@ -906,6 +906,23 @@ static void gen_jmp_tb(DisasContext *s, int n, uint32_t dest)
     s->is_jmp = DISAS_TB_JUMP;
 }
 
+DISAS_INSN(scc_mem)
+{
+    int l1;
+    int cond;
+    TCGv dest;
+
+    l1 = gen_new_label();
+    cond = (insn >> 8) & 0xf;
+    dest = tcg_temp_local_new();
+    tcg_gen_movi_i32(dest, 0);
+    gen_jmpcc(s, cond ^ 1, l1);
+    tcg_gen_movi_i32(dest, 0xff);
+    gen_set_label(l1);
+    DEST_EA(insn, OS_BYTE, dest, NULL);
+    tcg_temp_free(dest);
+}
+
 DISAS_INSN(undef_mac)
 {
     gen_exception(s, s->pc - 2, EXCP_LINEA);
@@ -2975,6 +2992,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(addsubq,   5000, f080, M68000);
     INSN(addsubq,   5080, f0c0, M68000);
     INSN(scc,       50c0, f0f8, CF_ISA_A);
+    INSN(scc_mem,   50c0, f0c0, M68000);
     INSN(scc,       50c0, f0f8, M68000);
     INSN(tpf,       51f8, fff8, CF_ISA_A);
 
Signature · 1 line
1.5.6.5
#7 lore raw

PATCH 7/17 m68k: add DBcc instruction.

Define DBcc instruction and attach it to M68000 feature.

---
 target-m68k/translate.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
target-m68k/translate.c +26 -0
index d08e1c8..f2a0c92 100644
@@ -923,6 +923,31 @@ DISAS_INSN(scc_mem)
     tcg_temp_free(dest);
 }
 
+DISAS_INSN(dbcc)
+{
+    int l1;
+    TCGv reg;
+    TCGv tmp;
+    int16_t offset;
+    uint32_t base;
+
+    reg = DREG(insn, 0);
+    base = s->pc;
+    offset = ldsw_code(s->pc);
+    s->pc += 2;
+    l1 = gen_new_label();
+    gen_jmpcc(s, (insn >> 8) & 0xf, l1);
+
+    tmp = tcg_temp_new();
+    tcg_gen_ext16s_i32(tmp, reg);
+    tcg_gen_addi_i32(tmp, tmp, -1);
+    gen_partset_reg(OS_WORD, reg, tmp);
+    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
+    gen_jmp_tb(s, 1, base + offset);
+    gen_set_label(l1);
+    gen_jmp_tb(s, 0, s->pc);
+}
+
 DISAS_INSN(undef_mac)
 {
     gen_exception(s, s->pc - 2, EXCP_LINEA);
@@ -2994,6 +3019,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(scc,       50c0, f0f8, CF_ISA_A);
     INSN(scc_mem,   50c0, f0c0, M68000);
     INSN(scc,       50c0, f0f8, M68000);
+    INSN(dbcc,      50c8, f0f8, M68000);
     INSN(tpf,       51f8, fff8, CF_ISA_A);
 
     /* Branch instructions.  */
Signature · 1 line
1.5.6.5
#8 lore raw

PATCH 8/17 m68k: modify movem instruction to manage word

This patch modifies "movem" to manage "word" and "long" register size instead of only "word". Attach it to M68000 feature.

---
 target-m68k/translate.c |   52 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 15 deletions(-)
target-m68k/translate.c +37 -15
index f2a0c92..c869cf9 100644
@@ -1176,6 +1176,8 @@ DISAS_INSN(movem)
     TCGv reg;
     TCGv tmp;
     int is_load;
+    int opsize;
+    int32_t incr;
 
     mask = lduw_code(s->pc);
     s->pc += 2;
@@ -1187,21 +1189,40 @@ DISAS_INSN(movem)
     addr = tcg_temp_new();
     tcg_gen_mov_i32(addr, tmp);
     is_load = ((insn & 0x0400) != 0);
-    for (i = 0; i < 16; i++, mask >>= 1) {
-        if (mask & 1) {
-            if (i < 8)
-                reg = DREG(i, 0);
-            else
-                reg = AREG(i, 0);
-            if (is_load) {
-                tmp = gen_load(s, OS_LONG, addr, 0);
-                tcg_gen_mov_i32(reg, tmp);
-            } else {
-                gen_store(s, OS_LONG, addr, reg);
-            }
-            if (mask != 1)
-                tcg_gen_addi_i32(addr, addr, 4);
-        }
+    opsize = (insn & 0x40) != 0 ? OS_LONG : OS_WORD;
+    incr = opsize_bytes(opsize);
+    if (!is_load && (insn & 070) == 040) {
+       for (i = 15; i >= 0; i--, mask >>= 1) {
+           if (mask & 1) {
+               if (i < 8)
+                   reg = DREG(i, 0);
+               else
+                   reg = AREG(i, 0);
+               gen_store(s, opsize, addr, reg);
+               if (mask != 1)
+                   tcg_gen_subi_i32(addr, addr, incr);
+           }
+       }
+       tcg_gen_mov_i32(AREG(insn, 0), addr);
+    } else {
+       for (i = 0; i < 16; i++, mask >>= 1) {
+           if (mask & 1) {
+               if (i < 8)
+                   reg = DREG(i, 0);
+               else
+                   reg = AREG(i, 0);
+               if (is_load) {
+                   tmp = gen_load(s, opsize, addr, 1);
+                   tcg_gen_mov_i32(reg, tmp);
+               } else {
+                   gen_store(s, opsize, addr, reg);
+               }
+               if (mask != 1 || (insn & 070) == 030)
+                   tcg_gen_addi_i32(addr, addr, incr);
+           }
+       }
+       if ((insn & 070) == 030)
+           tcg_gen_mov_i32(AREG(insn, 0), addr);
     }
 }
 
@@ -2975,6 +2996,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(swap,      4840, fff8, CF_ISA_A);
     INSN(swap,      4840, fff8, M68000);
     INSN(movem,     48c0, fbc0, CF_ISA_A);
+    INSN(movem,     48c0, fbc0, M68000);
     INSN(ext,       4880, fff8, CF_ISA_A);
     INSN(ext,       4880, fff8, M68000);
     INSN(ext,       48c0, fff8, CF_ISA_A);
Signature · 1 line
1.5.6.5
#9 lore raw

PATCH 9/17 m68k: add 64bit divide.

This patch modifies "divl" to support 64bit operands (QUAD_MULDIV feature).

---
 target-m68k/cpu.h       |    3 ++
 target-m68k/helpers.h   |    2 +
 target-m68k/op_helper.c |   77 ++++++++++++++++++++++++++++++++++++++++++++--
 target-m68k/qregs.def   |    1 +
 target-m68k/translate.c |   29 +++++++++++++++--
 5 files changed, 104 insertions(+), 8 deletions(-)
target-m68k/cpu.h +3 -0
index 240d75f..fa0b055 100644
@@ -91,6 +91,9 @@ typedef struct CPUM68KState {
     uint32_t div1;
     uint32_t div2;
 
+    /* Upper 32 bits of a 64bit operand for quad MUL/DIV.  */
+    uint32_t quadh;
+
     /* MMU status.  */
     struct {
         uint32_t ar;
target-m68k/helpers.h +2 -0
index cb8a0c7..a158aee 100644
@@ -5,6 +5,8 @@ DEF_HELPER_1(ff1, i32, i32)
 DEF_HELPER_2(sats, i32, i32, i32)
 DEF_HELPER_2(divu, void, env, i32)
 DEF_HELPER_2(divs, void, env, i32)
+DEF_HELPER_1(divu64, void, env)
+DEF_HELPER_1(divs64, void, env)
 DEF_HELPER_3(addx_cc, i32, env, i32, i32)
 DEF_HELPER_3(subx_cc, i32, env, i32, i32)
 DEF_HELPER_3(shl_cc, i32, env, i32, i32)
target-m68k/op_helper.c +73 -4

88 lines not on this page · raw message

target-m68k/qregs.def +1 -0
index 49400c4..76e0236 100644
@@ -7,6 +7,7 @@ DEFO32(CC_SRC, cc_src)
 DEFO32(CC_X, cc_x)
 DEFO32(DIV1, div1)
 DEFO32(DIV2, div2)
+DEFO32(QUADH, quadh)
 DEFO32(EXCEPTION, exception_index)
 DEFO32(HALTED, halted)
 DEFO32(MACSR, macsr)
target-m68k/translate.c +25 -4
index c869cf9..d0e223c 100644
@@ -1025,8 +1025,26 @@ DISAS_INSN(divl)
 
     ext = lduw_code(s->pc);
     s->pc += 2;
-    if (ext & 0x87f8) {
-        gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
+    if (ext & 0x400) {
+        if (!m68k_feature(s->env, M68K_FEATURE_QUAD_MULDIV)) {
+            gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
+            return;
+        }
+        num = DREG(ext, 12);
+        reg = DREG(ext, 0);
+        tcg_gen_mov_i32(QREG_DIV1, num);
+        tcg_gen_mov_i32(QREG_QUADH, reg);
+        SRC_EA(den, OS_LONG, 0, NULL);
+        tcg_gen_mov_i32(QREG_DIV2, den);
+        if (ext & 0x0800) {
+            gen_helper_divs64(cpu_env);
+        } else {
+            gen_helper_divu64(cpu_env);
+        }
+        tcg_gen_mov_i32(num, QREG_DIV1);
+        if (!TCGV_EQUAL(num, reg))
+            tcg_gen_mov_i32(reg, QREG_DIV2);
+        s->cc_op = CC_OP_FLAGS;
         return;
     }
     num = DREG(ext, 12);
@@ -1039,10 +1057,12 @@ DISAS_INSN(divl)
     } else {
         gen_helper_divu(cpu_env, tcg_const_i32(0));
     }
-    if ((ext & 7) == ((ext >> 12) & 7)) {
+    if (((ext & 7) == ((ext >> 12) & 7)) ||
+        m68k_feature(s->env, M68K_FEATURE_LONG_MULDIV)) {
         /* div */
         tcg_gen_mov_i32 (reg, QREG_DIV1);
-    } else {
+    }
+    if ((ext & 7) != ((ext >> 12) & 7)) {
         /* rem */
         tcg_gen_mov_i32 (reg, QREG_DIV2);
     }
@@ -3013,6 +3033,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(illegal,   4afc, ffff, M68000);
     INSN(mull,      4c00, ffc0, CF_ISA_A);
     INSN(divl,      4c40, ffc0, CF_ISA_A);
+    INSN(divl,      4c40, ffc0, LONG_MULDIV);
     INSN(sats,      4c80, fff8, CF_ISA_B);
     INSN(trap,      4e40, fff0, CF_ISA_A);
     INSN(trap,      4e40, fff0, M68000);
Signature · 1 line
1.5.6.5
#10 lore raw

PATCH 10/17 m68k: add 32bit and 64bit multiply

This patch modify "mull" to support 64bit result, and to update CC on 32bit operands.

---
 target-m68k/helpers.h   |    4 +++
 target-m68k/op_helper.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++
 target-m68k/translate.c |   36 +++++++++++++++++++++----
 3 files changed, 100 insertions(+), 6 deletions(-)
target-m68k/helpers.h +4 -0
index a158aee..ca2bf82 100644
@@ -7,6 +7,10 @@ DEF_HELPER_2(divu, void, env, i32)
 DEF_HELPER_2(divs, void, env, i32)
 DEF_HELPER_1(divu64, void, env)
 DEF_HELPER_1(divs64, void, env)
+DEF_HELPER_3(mulu32_cc, i32, env, i32, i32)
+DEF_HELPER_3(muls32_cc, i32, env, i32, i32)
+DEF_HELPER_3(mulu64, i32, env, i32, i32)
+DEF_HELPER_3(muls64, i32, env, i32, i32)
 DEF_HELPER_3(addx_cc, i32, env, i32, i32)
 DEF_HELPER_3(subx_cc, i32, env, i32, i32)
 DEF_HELPER_3(shl_cc, i32, env, i32, i32)
target-m68k/op_helper.c +66 -0

69 lines not on this page · raw message

target-m68k/translate.c +30 -6
index d0e223c..eed804e 100644
@@ -1635,22 +1635,45 @@ DISAS_INSN(mull)
     TCGv reg;
     TCGv src1;
     TCGv dest;
+    TCGv regh;
 
     /* The upper 32 bits of the product are discarded, so
        muls.l and mulu.l are functionally equivalent.  */
     ext = lduw_code(s->pc);
     s->pc += 2;
-    if (ext & 0x87ff) {
-        gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
-        return;
+    if (ext & 0x400) {
+       if (!m68k_feature(s->env, M68K_FEATURE_QUAD_MULDIV)) {
+           gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
+           return;
+       }
+       reg = DREG(ext, 12);
+       regh = DREG(ext, 0);
+       SRC_EA(src1, OS_LONG, 0, NULL);
+       dest = tcg_temp_new();
+       if (ext & 0x800)
+           gen_helper_muls64(dest, cpu_env, src1, reg);
+       else
+           gen_helper_mulu64(dest, cpu_env, src1, reg);
+       tcg_gen_mov_i32(reg, dest);
+       tcg_gen_mov_i32(regh, QREG_QUADH);
+       s->cc_op = CC_OP_FLAGS;
+       return;
     }
     reg = DREG(ext, 12);
     SRC_EA(src1, OS_LONG, 0, NULL);
     dest = tcg_temp_new();
-    tcg_gen_mul_i32(dest, src1, reg);
+    if (m68k_feature(s->env, M68K_FEATURE_M68000)) {
+       if (ext & 0x800)
+           gen_helper_muls32_cc(dest, cpu_env, src1, reg);
+       else
+           gen_helper_mulu32_cc(dest, cpu_env, src1, reg);
+       s->cc_op = CC_OP_FLAGS;
+    } else {
+       tcg_gen_mul_i32(dest, src1, reg);
+       /* Unlike m68k, coldfire always clears the overflow bit.  */
+       gen_logic_cc(s, dest);
+    }
     tcg_gen_mov_i32(reg, dest);
-    /* Unlike m68k, coldfire always clears the overflow bit.  */
-    gen_logic_cc(s, dest);
 }
 
 DISAS_INSN(link)
@@ -3032,6 +3055,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(illegal,   4afc, ffff, CF_ISA_A);
     INSN(illegal,   4afc, ffff, M68000);
     INSN(mull,      4c00, ffc0, CF_ISA_A);
+    INSN(mull,      4c00, ffc0, LONG_MULDIV);
     INSN(divl,      4c40, ffc0, CF_ISA_A);
     INSN(divl,      4c40, ffc0, LONG_MULDIV);
     INSN(sats,      4c80, fff8, CF_ISA_B);
Signature · 1 line
1.5.6.5
#11 lore raw

PATCH 11/17 m68k: add word data size for suba/adda

Allows suba and adda to manage word sized effective address, and attach them to M68000 feature.

---
 target-m68k/translate.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
target-m68k/translate.c +4 -2
index eed804e..89e5d5e 100644
@@ -1885,7 +1885,7 @@ DISAS_INSN(suba)
     TCGv src;
     TCGv reg;
 
-    SRC_EA(src, OS_LONG, 0, NULL);
+    SRC_EA(src, (insn & 0x100) ? OS_LONG : OS_WORD, -1, NULL);
     reg = AREG(insn, 9);
     tcg_gen_sub_i32(reg, reg, src);
 }
@@ -1995,7 +1995,7 @@ DISAS_INSN(adda)
     TCGv src;
     TCGv reg;
 
-    SRC_EA(src, OS_LONG, 0, NULL);
+    SRC_EA(src, (insn & 0x100) ? OS_LONG : OS_WORD, -1, NULL);
     reg = AREG(insn, 9);
     tcg_gen_add_i32(reg, reg, src);
 }
@@ -3113,6 +3113,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(subx,      9180, f1f8, CF_ISA_A);
     INSN(subx,      9100, f138, M68000);
     INSN(suba,      91c0, f1c0, CF_ISA_A);
+    INSN(suba,      90c0, f0c0, M68000);
 
     INSN(undef_mac, a000, f000, CF_ISA_A);
     INSN(undef_mac, a000, f000, M68000);
@@ -3148,6 +3149,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(addx,      d180, f1f8, CF_ISA_A);
     INSN(addx,      d100, f138, M68000);
     INSN(adda,      d1c0, f1c0, CF_ISA_A);
+    INSN(adda,      d0c0, f0c0, M68000);
     INSN(shift_im,  e080, f0f0, CF_ISA_A);
     INSN(shift_reg, e0a0, f0f0, CF_ISA_A);
     INSN(shift_im,    e080, f0f0, M68000);
Signature · 1 line
1.5.6.5
#12 lore raw

PATCH 12/17 m68k: add fpu

Modify "fpu" instruction to be compatible with 680x0 family and attach it to FPU feature (in addition to CF_FPU).

---
 target-m68k/translate.c |   49 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 7 deletions(-)
target-m68k/translate.c +42 -7
index 89e5d5e..d00bde3 100644
@@ -2346,18 +2346,43 @@ DISAS_INSN(fpu)
     case 7:
         {
             TCGv addr;
+            int incr;
             uint16_t mask;
             int i;
-            if ((ext & 0x1f00) != 0x1000 || (ext & 0xff) == 0)
+            if ((ext & 0xf00) != 0 || (ext & 0xff) == 0)
                 goto undef;
-            tmp32 = gen_lea(s, insn, OS_LONG);
-            if (IS_NULL_QREG(tmp32)) {
-                gen_addr_fault(s);
-                return;
+            if ((ext & 0x1000) == 0 && !m68k_feature(s->env, M68K_FEATURE_FPU))
+                goto undef;
+            if ((insn & 070) == 040)
+                tmp32 = AREG(insn, 0);
+            else {
+                tmp32 = gen_lea(s, insn, OS_LONG);
+                 if (IS_NULL_QREG(tmp32)) {
+                     gen_addr_fault(s);
+                     return;
+                 }
             }
             addr = tcg_temp_new_i32();
             tcg_gen_mov_i32(addr, tmp32);
             mask = 0x80;
+            if (m68k_feature(s->env, M68K_FEATURE_FPU))
+                incr = 12;
+            else
+                incr = 8;
+            if ((ext & (1 << 13)) && (insn & 070) == 040) {
+                for (i = 0; i < 8; i++) {
+                    if (ext & mask) {
+                        s->is_mem = 1;
+                        dest = FREG(i, 7);
+                        tcg_gen_subi_i32(addr, addr, incr);
+                        tcg_gen_mov_i32(AREG(insn, 0), addr);
+                        tcg_gen_qemu_stf64(dest, addr, IS_USER(s));
+                    }
+                    mask >>= 1;
+                }
+                tcg_temp_free_i32(addr);
+                return;
+            }
             for (i = 0; i < 8; i++) {
                 if (ext & mask) {
                     s->is_mem = 1;
@@ -2369,8 +2394,11 @@ DISAS_INSN(fpu)
                         /* load */
                         tcg_gen_qemu_ldf64(dest, addr, IS_USER(s));
                     }
-                    if (ext & (mask - 1))
-                        tcg_gen_addi_i32(addr, addr, 8);
+                    if (ext & (mask - 1) || (insn & 070) == 030) {
+                        tcg_gen_addi_i32(addr, addr, incr);
+                        if ((insn & 070) == 030)
+                            tcg_gen_mov_i32(AREG(insn, 0), addr);
+                    }
                 }
                 mask >>= 1;
             }
@@ -2478,6 +2506,12 @@ DISAS_INSN(fpu)
     case 0x23: case 0x63: case 0x67: /* fmul */
         gen_helper_mul_f64(res, cpu_env, res, src);
         break;
+    case 0x24:                      /* fsgldiv */
+        gen_helper_div_f64(res, cpu_env, res, src);
+        break;
+    case 0x27:                      /* fsglmul */ 
+        gen_helper_mul_f64(res, cpu_env, res, src);
+        break; 
     case 0x28: case 0x68: case 0x6c: /* fsub */
         gen_helper_sub_f64(res, cpu_env, res, src);
         break;
@@ -3160,6 +3194,7 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(fbcc,      f280, ffc0, CF_FPU);
     INSN(frestore,  f340, ffc0, CF_FPU);
     INSN(fsave,     f340, ffc0, CF_FPU);
+    INSN(fpu,       f200, ffc0, FPU);
     INSN(fbcc,      f280, ffc0, FPU);
     INSN(frestore,  f340, ffc0, FPU);
     INSN(fsave,     f340, ffc0, FPU);
Signature · 1 line
1.5.6.5
#13 lore raw

PATCH 13/17 m68k: add "byte", "word" and memory shift

This patch defines shift8_im, shift16_im, shift8_reg, shift16_reg, shift_mem and attach them to M68000 feature.

---
 target-m68k/cpu.h       |    2 +
 target-m68k/helper.c    |  160 +++++++++++++++++++++++++++--------------------
 target-m68k/helpers.h   |   12 +++-
 target-m68k/translate.c |  155 +++++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 249 insertions(+), 80 deletions(-)
target-m68k/cpu.h +2 -0
index fa0b055..727a0b1 100644
@@ -146,6 +146,8 @@ enum {
     CC_OP_SUBXB,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUBXW,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUBX,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SHIFTB, /* CC_DEST = result, CC_SRC = carry */
+    CC_OP_SHIFTW, /* CC_DEST = result, CC_SRC = carry */
     CC_OP_SHIFT, /* CC_DEST = result, CC_SRC = carry */
 };
 
target-m68k/helper.c +96 -74

189 lines not on this page · raw message

target-m68k/helpers.h +9 -3
index ca2bf82..d1993ab 100644
@@ -13,9 +13,15 @@ DEF_HELPER_3(mulu64, i32, env, i32, i32)
 DEF_HELPER_3(muls64, i32, env, i32, i32)
 DEF_HELPER_3(addx_cc, i32, env, i32, i32)
 DEF_HELPER_3(subx_cc, i32, env, i32, i32)
-DEF_HELPER_3(shl_cc, i32, env, i32, i32)
-DEF_HELPER_3(shr_cc, i32, env, i32, i32)
-DEF_HELPER_3(sar_cc, i32, env, i32, i32)
+DEF_HELPER_3(shl8_cc, i32, env, i32, i32)
+DEF_HELPER_3(shl16_cc, i32, env, i32, i32)
+DEF_HELPER_3(shl32_cc, i32, env, i32, i32)
+DEF_HELPER_3(shr8_cc, i32, env, i32, i32)
+DEF_HELPER_3(shr16_cc, i32, env, i32, i32)
+DEF_HELPER_3(shr32_cc, i32, env, i32, i32)
+DEF_HELPER_3(sar8_cc, i32, env, i32, i32)
+DEF_HELPER_3(sar16_cc, i32, env, i32, i32)
+DEF_HELPER_3(sar32_cc, i32, env, i32, i32)
 DEF_HELPER_2(xflag_lt, i32, i32, i32)
 DEF_HELPER_2(set_sr, void, env, i32)
 DEF_HELPER_3(movec, void, env, i32, i32)
target-m68k/translate.c +147 -8

195 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#14 lore raw

PATCH 14/17 m68k: add "byte", "word" and memory rotate.

Add rotate_im, rotate8_im, rotate16_im, rotate_reg, rotate8_reg, rotate16_reg,
rotate_mem and attach them to M68000 feature.

---
 target-m68k/exec.h      |    4 +
 target-m68k/helper.c    |  149 ++++++++++++++++++++++++++++++++++
 target-m68k/helpers.h   |   12 +++
 target-m68k/translate.c |  205 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 370 insertions(+), 0 deletions(-)
target-m68k/exec.h +4 -0
index 3a86b1f..6f63cd8 100644
@@ -29,6 +29,10 @@ register uint32_t T0 asm(AREG1);
 #include "cpu.h"
 #include "exec-all.h"
 
+extern const uint8_t rox8_table[64];
+extern const uint8_t rox16_table[64];
+extern const uint8_t rox32_table[64];
+
 static inline void env_to_regs(void)
 {
 }
target-m68k/helper.c +149 -0

161 lines not on this page · raw message

target-m68k/helpers.h +12 -0
index d1993ab..07d1f82 100644
@@ -22,6 +22,18 @@ DEF_HELPER_3(shr32_cc, i32, env, i32, i32)
 DEF_HELPER_3(sar8_cc, i32, env, i32, i32)
 DEF_HELPER_3(sar16_cc, i32, env, i32, i32)
 DEF_HELPER_3(sar32_cc, i32, env, i32, i32)
+DEF_HELPER_3(rol8_cc, i32, env, i32, i32)
+DEF_HELPER_3(rol16_cc, i32, env, i32, i32)
+DEF_HELPER_3(rol32_cc, i32, env, i32, i32)
+DEF_HELPER_3(ror8_cc, i32, env, i32, i32)
+DEF_HELPER_3(ror16_cc, i32, env, i32, i32)
+DEF_HELPER_3(ror32_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxr8_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxr16_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxr32_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxl8_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxl16_cc, i32, env, i32, i32)
+DEF_HELPER_3(roxl32_cc, i32, env, i32, i32)
 DEF_HELPER_2(xflag_lt, i32, i32, i32)
 DEF_HELPER_2(set_sr, void, env, i32)
 DEF_HELPER_3(movec, void, env, i32, i32)
target-m68k/translate.c +205 -0

217 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#15 lore raw

PATCH 15/17 m68k: add bitfield_mem, bitfield_reg

This patch implements bitfields instructions: bftst, bfextu, bfexts, bfffo, bfchg, bfclr, bfset, bfins and attach them to BITFIELD feature.

---
 target-m68k/helper.c    |   27 ++++
 target-m68k/helpers.h   |    3 +
 target-m68k/translate.c |  323 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 353 insertions(+), 0 deletions(-)
target-m68k/helper.c +27 -0
index 92c7621..32ff8ca 100644
@@ -514,6 +514,33 @@ uint32_t HELPER(ff1)(uint32_t x)
     return n;
 }
 
+uint32_t HELPER(bfffo)(uint32_t arg, uint32_t width)
+{
+    int n;
+    uint32_t mask;
+    mask = 0x80000000;
+    for (n = 0; n < width; n++) {
+       if (arg & mask)
+           break;
+       mask >>= 1;
+    }
+    return n;
+}
+
+uint32_t HELPER(rol32)(uint32_t val, uint32_t shift)
+{
+    uint32_t result;
+    result = (val << shift) | (val >> (32 - shift));
+    return result;
+}
+
+uint32_t HELPER(ror32)(uint32_t val, uint32_t shift)
+{
+    uint32_t result;
+    result = (val >> shift) | (val << (32 - shift));
+    return result;
+}
+
 uint32_t HELPER(sats)(uint32_t val, uint32_t ccr)
 {
     /* The result has the opposite sign to the original value.  */
target-m68k/helpers.h +3 -0
index 07d1f82..949d5d5 100644
@@ -2,6 +2,9 @@
 
 DEF_HELPER_1(bitrev, i32, i32)
 DEF_HELPER_1(ff1, i32, i32)
+DEF_HELPER_2(bfffo, i32, i32, i32)
+DEF_HELPER_2(rol32, i32, i32, i32)
+DEF_HELPER_2(ror32, i32, i32, i32)
 DEF_HELPER_2(sats, i32, i32, i32)
 DEF_HELPER_2(divu, void, env, i32)
 DEF_HELPER_2(divs, void, env, i32)
target-m68k/translate.c +323 -0

335 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#16 lore raw

PATCH 16/17 m68k: add variable offset/width to bitfield_reg/bitfield_mem

This patch allows bitfield instructions to read bit offset and field size from a register instead of an immediat value.

---
 target-m68k/helper.c    |   42 ++++
 target-m68k/helpers.h   |    2 +
 target-m68k/translate.c |  517 +++++++++++++++++++++++------------------------
 3 files changed, 292 insertions(+), 269 deletions(-)
target-m68k/helper.c +42 -0
index 32ff8ca..3ae0366 100644
@@ -530,6 +530,8 @@ uint32_t HELPER(bfffo)(uint32_t arg, uint32_t width)
 uint32_t HELPER(rol32)(uint32_t val, uint32_t shift)
 {
     uint32_t result;
+    if (shift == 0 || shift == 32)
+        return val;
     result = (val << shift) | (val >> (32 - shift));
     return result;
 }
@@ -537,6 +539,8 @@ uint32_t HELPER(rol32)(uint32_t val, uint32_t shift)
 uint32_t HELPER(ror32)(uint32_t val, uint32_t shift)
 {
     uint32_t result;
+    if (shift == 0 || shift == 32)
+        return val;
     result = (val >> shift) | (val << (32 - shift));
     return result;
 }
@@ -1182,3 +1186,41 @@ void HELPER(set_mac_extu)(CPUState *env, uint32_t val, uint32_t acc)
     res |= (uint64_t)(val & 0xffff0000) << 16;
     env->macc[acc + 1] = res;
 }
+
+/* load from a bitfield */
+
+uint64_t HELPER(bitfield_load)(uint32_t addr, uint32_t offset, uint32_t width)
+{
+    uint8_t data[8];
+    uint64_t bitfield;
+    int size;
+    int i;
+
+    size = (offset + width + 7) >> 3;
+    cpu_physical_memory_rw(addr, data, size, 0);
+
+    bitfield = data[0];
+    for (i = 1; i < 8; i++)
+        bitfield = (bitfield << 8) | data[i];
+
+    return bitfield;
+}
+
+/* store to a bitfield */
+
+void HELPER(bitfield_store)(uint32_t addr, uint32_t offset, uint32_t width,
+                            uint64_t bitfield)
+{
+    uint8_t data[8];
+    int size;
+    int i;
+
+    size = (offset + width + 7) >> 3;
+
+    for (i = 0; i < 8; i++) {
+        data[7 - i] = bitfield;
+        bitfield >>= 8;
+    }
+
+    cpu_physical_memory_rw(addr, data, size, 1);
+}
target-m68k/helpers.h +2 -0
index 949d5d5..d71ed26 100644
@@ -78,4 +78,6 @@ DEF_HELPER_3(set_mac_extu, void, env, i32, i32)
 DEF_HELPER_2(flush_flags, void, env, i32)
 DEF_HELPER_1(raise_exception, void, i32)
 
+DEF_HELPER_3(bitfield_load, i64, i32, i32, i32);
+DEF_HELPER_4(bitfield_store, void, i32, i32, i32, i64);
 #include "def-helper.h"
target-m68k/translate.c +248 -269

570 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#17 lore raw

PATCH 17/17 m68k: add cas

This instruction is needed to execute commands like "ls" or "date" (from a debian lenny m68k).

It define a new feaure, CAS, and attach this new instruction to it.

---
 target-m68k/cpu.h       |    3 +-
 target-m68k/helper.c    |    2 +
 target-m68k/translate.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletions(-)
target-m68k/cpu.h +2 -1
index 727a0b1..93956c3 100644
@@ -209,7 +209,8 @@ enum m68k_features {
     M68K_FEATURE_QUAD_MULDIV,	/* 64 bit multiply/divide. */
     M68K_FEATURE_BCCL,		/* Long conditional branches.  */
     M68K_FEATURE_BITFIELD,	/* Bit field insns.  */
-    M68K_FEATURE_FPU
+    M68K_FEATURE_FPU,
+    M68K_FEATURE_CAS
 };
 
 static inline int m68k_feature(CPUM68KState *env, int feature)
target-m68k/helper.c +2 -0
index 3ae0366..67e823a 100644
@@ -162,6 +162,7 @@ static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
         m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
         m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
         m68k_set_feature(env, M68K_FEATURE_FPU);
+        m68k_set_feature(env, M68K_FEATURE_CAS);
     case M68K_CPUID_M68000:
         m68k_set_feature(env, M68K_FEATURE_M68000);
         m68k_set_feature(env, M68K_FEATURE_USP);
@@ -207,6 +208,7 @@ static int cpu_m68k_set_model(CPUM68KState *env, const char *name)
         m68k_set_feature(env, M68K_FEATURE_BITFIELD);
         m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
         m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
+        m68k_set_feature(env, M68K_FEATURE_CAS);
         break;
     }
 
target-m68k/translate.c +62 -0

74 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#18 lore raw

[Qemu-devel] Re: [PATCH 17/17] m68k: add cas

Quoted 5 lines · Laurent Vivier
(quoted diff) +5 -0
+    cmp = DREG(ext, 0);
+    update = DREG(ext, 6);
+    tmp = gen_load(s, opsize, addr, 0);
+    dest = tcg_temp_local_new();
+    tcg_gen_mov_i32(dest, tmp);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+    res = tcg_temp_new();
+    tcg_gen_sub_i32(res, dest, cmp);
+    gen_logic_cc(s, res);
+
+    l1 = gen_new_label();
+    l2 = gen_new_label();
+
+    gen_jmpcc(s, 6 /* !Z */, l1);
+    gen_store(s, opsize, addr, update);

This has a bug: addr is used around a jump.

Andreas.
---

Quoted 1 line

From b87bc72daf28f519017c79615b962c47a1e0492d Mon Sep 17 00:00:00 2001

From: Andreas Schwab <[email protected]>
Date: Sat, 30 May 2009 15:32:20 +0200
Subject: [PATCH] m68k: fix use of temporary around jump

---
 target-m68k/translate.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
target-m68k/translate.c +7 -3
index 4372975..9d68b02 100644
@@ -1382,6 +1382,7 @@ DISAS_INSN(cas)
     TCGv tmp;
     TCGv cmp;
     TCGv update;
+    TCGv taddr;
     TCGv addr;
     TCGv res;
     uint16_t ext;
@@ -1408,17 +1409,19 @@ DISAS_INSN(cas)
 
     ext = lduw_code(s->pc);
     s->pc += 2;
-    addr = gen_lea(s, insn, opsize);
-    if (IS_NULL_QREG(addr)) {
+    taddr = gen_lea(s, insn, opsize);
+    if (IS_NULL_QREG(taddr)) {
         gen_addr_fault(s);
         return;
     }
 
     cmp = DREG(ext, 0);
     update = DREG(ext, 6);
-    tmp = gen_load(s, opsize, addr, 0);
+    tmp = gen_load(s, opsize, taddr, 0);
     dest = tcg_temp_local_new();
     tcg_gen_mov_i32(dest, tmp);
+    addr = tcg_temp_local_new ();
+    tcg_gen_mov_i32(addr, taddr);
 
     res = tcg_temp_new();
     tcg_gen_sub_i32(res, dest, cmp);
@@ -1434,6 +1437,7 @@ DISAS_INSN(cas)
     tcg_gen_mov_i32(cmp, dest);
     gen_set_label(l2);
     tcg_temp_free(dest);
+    tcg_temp_free(addr);
 }
 
 DISAS_INSN(byterev)
Signature · 7 lines
1.6.3.1


-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#19 lore raw

Re: [Qemu-devel] Re: [PATCH 17/17] m68k: add cas

Quoted 11 lines · Andreas Schwab
Quoted 9 lines · Laurent Vivier
(quoted diff) +9 -0
+    cmp = DREG(ext, 0);
+    update = DREG(ext, 6);
+    tmp = gen_load(s, opsize, addr, 0);
+    dest = tcg_temp_local_new();
+    tcg_gen_mov_i32(dest, tmp);
+
+    res = tcg_temp_new();
+    tcg_gen_sub_i32(res, dest, cmp);
+    gen_logic_cc(s, res);
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+
+    l1 = gen_new_label();
+    l2 = gen_new_label();
+
+    gen_jmpcc(s, 6 /* !Z */, l1);
+    gen_store(s, opsize, addr, update);

This has a bug: addr is used around a jump.

I agree, thank you.
(I didn't read tcg/README correctly...)

Laurent

#20 lore raw

[Qemu-devel] Re: [PATCH 07/17] m68k: add DBcc instruction.

In reply to Laurent Vivier

Review

Quoted 5 lines · Laurent Vivier
(quoted diff) +5 -0
+    tmp = tcg_temp_new();
+    tcg_gen_ext16s_i32(tmp, reg);
+    tcg_gen_addi_i32(tmp, tmp, -1);
+    gen_partset_reg(OS_WORD, reg, tmp);
+    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);

The counter needs to be compared with -1, not 0.

Andreas.
---

Quoted 1 line

From 07f10a1b4a4aa4a54468e1106a4bbc28c5ada45e Mon Sep 17 00:00:00 2001

From: Andreas Schwab <[email protected]>
Date: Sat, 30 May 2009 23:52:11 +0200
Subject: [PATCH] m68k: fix decoding of dbcc

The counter needs to be compared with -1, not 0.

---
 target-m68k/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-m68k/translate.c +1 -1
index 9d68b02..ea6b34b 100644
@@ -942,7 +942,7 @@ DISAS_INSN(dbcc)
     tcg_gen_ext16s_i32(tmp, reg);
     tcg_gen_addi_i32(tmp, tmp, -1);
     gen_partset_reg(OS_WORD, reg, tmp);
-    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
+    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, -1, l1);
     gen_jmp_tb(s, 1, base + offset);
     gen_set_label(l1);
     gen_jmp_tb(s, 0, s->pc);
Signature · 6 lines
1.6.3.1

-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#21 lore raw

[Qemu-devel] Re: [PATCH 07/17] m68k: add DBcc instruction.

Quoted 9 lines · Andreas Schwab

Review

Quoted 5 lines · Laurent Vivier
(quoted diff) +5 -0
+    tmp = tcg_temp_new();
+    tcg_gen_ext16s_i32(tmp, reg);
+    tcg_gen_addi_i32(tmp, tmp, -1);
+    gen_partset_reg(OS_WORD, reg, tmp);
+    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);

The counter needs to be compared with -1, not 0.

Yes, "ls -l" works better, now.

Laurent

Quoted 30 lines

Andreas.
---
From 07f10a1b4a4aa4a54468e1106a4bbc28c5ada45e Mon Sep 17 00:00:00 2001
From: Andreas Schwab <[email protected]>
Date: Sat, 30 May 2009 23:52:11 +0200
Subject: [PATCH] m68k: fix decoding of dbcc

The counter needs to be compared with -1, not 0.

---
 target-m68k/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-m68k/translate.c +1 -1
index 9d68b02..ea6b34b 100644
@@ -942,7 +942,7 @@ DISAS_INSN(dbcc)
     tcg_gen_ext16s_i32(tmp, reg);
     tcg_gen_addi_i32(tmp, tmp, -1);
     gen_partset_reg(OS_WORD, reg, tmp);
-    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
+    tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, -1, l1);
     gen_jmp_tb(s, 1, base + offset);
     gen_set_label(l1);
     gen_jmp_tb(s, 0, s->pc);
Signature · 1 line
1.6.3.1
#22 lore raw

Re: [Qemu-devel] [PATCH 04/17] m68k: add missing accessing modes for some instructions.

In reply to Laurent Vivier

I just happened to notice these:

Quoted 1 line · Laurent Vivier

+/* Read a 8-bit immediat constant */

Should be:
/* Read an 8-bit immediate constant */
^ ^

Quoted 1 line

+/* Read a 16-bit immediat constant */

Should be:
/* Read a 16-bit immediate constant */

                            ^

If I knew more about the M68K, perhaps I'd be of more help... :/

Cheers,

Signature · 1 line
Stuart Brady
#23 lore raw

Re: [Qemu-devel] [PATCH 04/17] m68k: add missing accessing modes for some instructions.

Quoted 9 lines · Stuart Brady

I just happened to notice these:

Quoted 1 line · Laurent Vivier

+/* Read a 8-bit immediat constant */

Should be:

   /* Read an 8-bit immediate constant */
            ^               ^
Quoted 7 lines
Quoted 1 line

+/* Read a 16-bit immediat constant */

Should be:

   /* Read a 16-bit immediate constant */
                            ^

If I knew more about the M68K, perhaps I'd be of more help... :/

Corrected, thank you.

Regards,
Laurent

#24 lore raw
In reply to Laurent Vivier
Quoted 3 lines

This series of patches is a port to Qemu 0.10 of Andreas Schwab M68K patch
to support Motorola 680x0 CPU family.

Ohh cool, now I just need to add a real system target to test my Haiku port :)

François.

#25 lore raw
In reply to Laurent Vivier
Quoted 4 lines · On Friday 29 May 2009 17:41:44 Laurent Vivier wrote:

This series of patches is a port to Qemu 0.10 of Andreas Schwab M68K patch to support Motorola 680x0 CPU family.

It has been tested with some commands from a debian m68k lenny disk.

Has there been any progress on this? (Or current versions I can test?)

I have a cross compiler, root filesystem, and kernel built for m68k, but no test environment. Charles Stevens got a system image running under aranym, but that has several limitations (such as no serial I/O, which makes a serial console problematic), and I'm testing all my other targets on qemu.

All the current system images are coldfire, which I haven't played with because I haven't done any nommu targets yet. Presumably I could shoehorn a real m68k into a coldfire system emulation, assuming I could beat a relevant .config out of the kernel...

Rob

Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds