[40/52] target-m68k: add exg ops
diff mbox

Message ID 1462396869-22424-1-git-send-email-laurent@vivier.eu
State New
Headers show

Commit Message

Laurent Vivier May 4, 2016, 9:20 p.m. UTC
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 target-m68k/translate.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Richard Henderson May 6, 2016, 9:47 p.m. UTC | #1
On 05/04/2016 11:20 AM, Laurent Vivier wrote:
> +    case 0x140:
> +        /* exchange Dx and Dy */
> +        src = DREG(insn, 9);
> +        reg = DREG(insn, 0);
> +        tcg_gen_mov_i32(dest, src);
> +        tcg_gen_mov_i32(src, reg);
> +        tcg_gen_mov_i32(reg, dest);
> +        break;
> +    case 0x148:
> +        /* exchange Ax and Ay */
> +        src = AREG(insn, 9);
> +        reg = AREG(insn, 0);
> +        tcg_gen_mov_i32(dest, src);
> +        tcg_gen_mov_i32(src, reg);
> +        tcg_gen_mov_i32(reg, dest);
> +        break;
> +    case 0x188:
> +        /* exchange Dx and Ay */
> +        src = DREG(insn, 9);
> +        reg = AREG(insn, 0);
> +        tcg_gen_mov_i32(dest, src);
> +        tcg_gen_mov_i32(src, reg);
> +        tcg_gen_mov_i32(reg, dest);
> +        break;
> +    }

All of the mov's can surely be shared between these cases.

Otherwise,

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

Patch
diff mbox

diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 53c3c41..df5ce94 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -2721,6 +2721,45 @@  DISAS_INSN(eor)
     DEST_EA(env, insn, OS_LONG, dest, &addr);
 }
 
+DISAS_INSN(exg)
+{
+    TCGv src;
+    TCGv reg;
+    TCGv dest;
+    int exg_mode;
+
+    exg_mode = insn & 0x1f8;
+
+    dest = tcg_temp_new();
+    switch (exg_mode) {
+    case 0x140:
+        /* exchange Dx and Dy */
+        src = DREG(insn, 9);
+        reg = DREG(insn, 0);
+        tcg_gen_mov_i32(dest, src);
+        tcg_gen_mov_i32(src, reg);
+        tcg_gen_mov_i32(reg, dest);
+        break;
+    case 0x148:
+        /* exchange Ax and Ay */
+        src = AREG(insn, 9);
+        reg = AREG(insn, 0);
+        tcg_gen_mov_i32(dest, src);
+        tcg_gen_mov_i32(src, reg);
+        tcg_gen_mov_i32(reg, dest);
+        break;
+    case 0x188:
+        /* exchange Dx and Ay */
+        src = DREG(insn, 9);
+        reg = AREG(insn, 0);
+        tcg_gen_mov_i32(dest, src);
+        tcg_gen_mov_i32(src, reg);
+        tcg_gen_mov_i32(reg, dest);
+        break;
+    }
+    tcg_temp_free(dest);
+}
+
 DISAS_INSN(and)
 {
     TCGv src;
@@ -4785,6 +4824,12 @@  void register_m68k_insns (CPUM68KState *env)
     INSN(cmpa,      b0c0, f0c0, M68000);
     INSN(eor,       b180, f1c0, CF_ISA_A);
     BASE(and,       c000, f000);
+    INSN(undef,     c140, f1f8, CF_ISA_A);
+    INSN(exg,       c140, f1f8, M68000);
+    INSN(undef,     c148, f1f8, CF_ISA_A);
+    INSN(exg,       c148, f1f8, M68000);
+    INSN(undef,     c188, f1f8, CF_ISA_A);
+    INSN(exg,       c188, f1f8, M68000);
     BASE(mulw,      c0c0, f0c0);
     INSN(abcd_reg,  c100, f1f8, M68000);
     INSN(abcd_mem,  c108, f1f8, M68000);