From patchwork Sun Aug 9 20:13:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 505458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 91FCD1401C7 for ; Mon, 10 Aug 2015 06:18:43 +1000 (AEST) Received: from localhost ([::1]:56148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOX3J-0000tG-MG for incoming@patchwork.ozlabs.org; Sun, 09 Aug 2015 16:18:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOWz1-0000Uf-7g for qemu-devel@nongnu.org; Sun, 09 Aug 2015 16:14:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOWyz-0005Oi-VS for qemu-devel@nongnu.org; Sun, 09 Aug 2015 16:14:15 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:40736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOWyz-0005OW-PH for qemu-devel@nongnu.org; Sun, 09 Aug 2015 16:14:13 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 1061C4C80A8; Sun, 9 Aug 2015 22:14:13 +0200 (CEST) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Sun, 9 Aug 2015 22:13:31 +0200 Message-Id: <1439151229-27747-13-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1439151229-27747-1-git-send-email-laurent@vivier.eu> References: <1439151229-27747-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Andreas Schwab , Laurent Vivier , gerg@uclinux.org Subject: [Qemu-devel] [PATCH for-2.5 12/30] m68k: Manage divw overflow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org "Overflow may be detected and set before the instruction completes. If the instruction detects an overflow, it sets the overflow condition code, and the operands are unaffected." Signed-off-by: Laurent Vivier --- target-m68k/translate.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 8a3d315..370a2f0 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -1034,32 +1034,40 @@ DISAS_INSN(mulw) DISAS_INSN(divw) { - TCGv reg; + TCGv dest; TCGv tmp; TCGv src; int sign; + TCGLabel *l1; sign = (insn & 0x100) != 0; - reg = DREG(insn, 9); - if (sign) { - tcg_gen_ext16s_i32(QREG_DIV1, reg); - } else { - tcg_gen_ext16u_i32(QREG_DIV1, reg); - } + + /* dest.l / src.w */ + + dest = DREG(insn, 9); + tcg_gen_mov_i32(QREG_DIV1, dest); + SRC_EA(env, src, OS_WORD, sign, NULL); tcg_gen_mov_i32(QREG_DIV2, src); + + /* div1 / div2 */ + if (sign) { gen_helper_divs(cpu_env, tcg_const_i32(1)); } else { gen_helper_divu(cpu_env, tcg_const_i32(1)); } + set_cc_op(s, CC_OP_FLAGS); + + l1 = gen_new_label(); + gen_jmpcc(s, 9 /* V */, l1); tmp = tcg_temp_new(); src = tcg_temp_new(); tcg_gen_ext16u_i32(tmp, QREG_DIV1); tcg_gen_shli_i32(src, QREG_DIV2, 16); - tcg_gen_or_i32(reg, tmp, src); - set_cc_op(s, CC_OP_FLAGS); + tcg_gen_or_i32(dest, tmp, src); + gen_set_label(l1); } DISAS_INSN(divl)