Patchwork [025/111] m68k: add cas

login
register
mail settings
Submitter Bryce Lanham
Date Aug. 17, 2011, 8:46 p.m.
Message ID <1313614076-28878-26-git-send-email-blanham@gmail.com>
Download mbox | patch
Permalink /patch/110409/
State New
Headers show

Comments

Bryce Lanham - Aug. 17, 2011, 8:46 p.m.
From: Andreas Schwab <schwab@linux-m68k.org>

Laurent Vivier <laurent@vivier.eu> writes:

> +    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);
> +
> +    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.
---
 target-m68k/translate.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

Patch

diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index c186fe1..218210c 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -1378,6 +1378,7 @@  DISAS_INSN(cas)
     TCGv tmp;
     TCGv cmp;
     TCGv update;
+    TCGv taddr;
     TCGv addr;
     TCGv res;
     uint16_t ext;
@@ -1404,17 +1405,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);
@@ -1430,6 +1433,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)