Index: qemu/target-sparc/translate.c
===================================================================
--- qemu.orig/target-sparc/translate.c	2008-03-01 08:33:10.000000000 +0000
+++ qemu/target-sparc/translate.c	2008-03-01 11:03:42.000000000 +0000
@@ -991,6 +991,80 @@
 }
 #endif
 
+/* old op:
+    if (!T0)
+        env->psr |= PSR_ZERO;
+    if ((int32_t) T0 < 0)
+        env->psr |= PSR_NEG;
+*/
+void gen_cc_NZ(TCGv reg)
+{
+    TCGv r_zero, r_flag;
+    int l1, l2;
+
+    l1 = gen_new_label();
+    l2 = gen_new_label();
+
+    r_zero = tcg_temp_new(TCG_TYPE_I32);
+    r_flag = tcg_temp_new(TCG_TYPE_I32);
+    tcg_gen_movi_i32(r_zero, 0);
+    tcg_gen_mov_i32(r_flag, r_zero);
+    tcg_gen_brcond_i32(TCG_COND_NE, reg, r_zero, l1);
+    tcg_gen_movi_i32(r_flag, PSR_ZERO);
+    gen_set_label(l1);
+    tcg_gen_brcond_i32(TCG_COND_GE, reg, r_zero, l2);
+    tcg_gen_ori_i32(r_flag, r_flag, PSR_NEG);
+    gen_set_label(l2);
+    tcg_gen_st_i32(r_flag, cpu_env, offsetof(CPUSPARCState, psr));
+}
+
+/* old op:
+    if (T0 < src1)
+        env->psr |= PSR_CARRY;
+*/
+void gen_cc_C_add(TCGv reg, TCGv oldreg)
+{
+    TCGv r_flag;
+    int l1;
+
+    l1 = gen_new_label();
+
+    tcg_gen_brcond_i32(TCG_COND_GEU, reg, oldreg, l1);
+    r_flag = tcg_temp_new(TCG_TYPE_I32);
+    tcg_gen_ld_i32(r_flag, cpu_env, offsetof(CPUSPARCState, psr));
+    tcg_gen_ori_i32(r_flag, r_flag, PSR_CARRY);
+    tcg_gen_st_i32(r_flag, cpu_env, offsetof(CPUSPARCState, psr));
+    gen_set_label(l1);
+}
+
+/* old op:
+    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
+        env->psr |= PSR_OVF;
+*/
+void gen_cc_V_add(TCGv reg, TCGv reg2, TCGv oldreg)
+{
+    TCGv r_flag, r_temp, r_temp2, r_zero;
+    int l1;
+
+    l1 = gen_new_label();
+
+    r_temp = tcg_temp_new(TCG_TYPE_I32);
+    r_temp2 = tcg_temp_new(TCG_TYPE_I32);
+    r_zero = tcg_temp_new(TCG_TYPE_I32);
+    tcg_gen_xor_i32(r_temp, oldreg, reg2);
+    tcg_gen_xori_i32(r_temp, r_temp, -1);
+    tcg_gen_xor_i32(r_temp2, oldreg, reg);
+    tcg_gen_and_i32(r_temp, r_temp, r_temp2);
+    tcg_gen_andi_i32(r_temp, r_temp, (1 << 31));
+    tcg_gen_movi_i32(r_zero, 0);
+    tcg_gen_brcond_i32(TCG_COND_EQ, r_temp, r_zero, l1);
+    r_flag = tcg_temp_new(TCG_TYPE_I32);
+    tcg_gen_ld_i32(r_flag, cpu_env, offsetof(CPUSPARCState, psr));
+    tcg_gen_ori_i32(r_flag, r_flag, PSR_OVF);
+    tcg_gen_st_i32(r_flag, cpu_env, offsetof(CPUSPARCState, psr));
+    gen_set_label(l1);
+}
+
 /* before an instruction, dc->pc must be static */
 static void disas_sparc_insn(DisasContext * dc)
 {
@@ -2067,9 +2141,17 @@
                 if (xop < 0x20) {
                     switch (xop & ~0x10) {
                     case 0x0:
-                        if (xop & 0x10)
+                        if (xop & 0x10) {
+#ifdef TARGET_SPARC64
                             gen_op_add_T1_T0_cc();
-                        else
+#else
+                            tcg_gen_mov_tl(cpu_tmp0, cpu_T[0]);
+                            tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
+                            gen_cc_NZ(cpu_T[0]);
+                            gen_cc_C_add(cpu_T[0], cpu_tmp0);
+                            gen_cc_V_add(cpu_T[0], cpu_T[1], cpu_tmp0);
+#endif
+                        } else
                             gen_op_add_T1_T0();
                         break;
                     case 0x1:
Index: qemu/target-sparc/op.c
===================================================================
--- qemu.orig/target-sparc/op.c	2008-03-01 10:32:19.000000000 +0000
+++ qemu/target-sparc/op.c	2008-03-01 10:32:56.000000000 +0000
@@ -175,6 +175,7 @@
 
 #define FLAG_SET(x) ((env->psr&x)?1:0)
 
+#ifdef TARGET_SPARC64
 void OPPROTO op_add_T1_T0_cc(void)
 {
     target_ulong src1;
@@ -182,7 +183,6 @@
     src1 = T0;
     T0 += T1;
     env->psr = 0;
-#ifdef TARGET_SPARC64
     if (!(T0 & 0xffffffff))
         env->psr |= PSR_ZERO;
     if ((int32_t) T0 < 0)
@@ -202,18 +202,9 @@
         env->xcc |= PSR_CARRY;
     if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
         env->xcc |= PSR_OVF;
-#else
-    if (!T0)
-        env->psr |= PSR_ZERO;
-    if ((int32_t) T0 < 0)
-        env->psr |= PSR_NEG;
-    if (T0 < src1)
-        env->psr |= PSR_CARRY;
-    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
-        env->psr |= PSR_OVF;
-#endif
     FORCE_RET();
 }
+#endif
 
 void OPPROTO op_addx_T1_T0(void)
 {
