From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOWz1-0000Vb-KO 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 1ZOWz0-0005P6-Ej for qemu-devel@nongnu.org; Sun, 09 Aug 2015 16:14:15 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:40769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOWz0-0005Oq-95 for qemu-devel@nongnu.org; Sun, 09 Aug 2015 16:14:14 -0400 From: Laurent Vivier Date: Sun, 9 Aug 2015 22:13:32 +0200 Message-Id: <1439151229-27747-14-git-send-email-laurent@vivier.eu> In-Reply-To: <1439151229-27747-1-git-send-email-laurent@vivier.eu> References: <1439151229-27747-1-git-send-email-laurent@vivier.eu> Subject: [Qemu-devel] [PATCH for-2.5 13/30] m68k: set Z and N on divu/muls overflow as a real 68040 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Andreas Schwab , Laurent Vivier , gerg@uclinux.org This allows to compare simulation results with a real 68040. Signed-off-by: Laurent Vivier --- target-m68k/op_helper.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c index 1af0ca6..71641bf 100644 --- a/target-m68k/op_helper.c +++ b/target-m68k/op_helper.c @@ -193,12 +193,19 @@ void HELPER(divu)(CPUM68KState *env, uint32_t word) quot = num / den; rem = num % den; flags = 0; - if (word && quot > 0xffff) - flags |= CCF_V; - if (quot == 0) - flags |= CCF_Z; - else if ((int32_t)quot < 0) - flags |= CCF_N; + if (word && quot > 0xffff) { + /* real 68040 keep Z and N on overflow, + * whereas documentation says "undefined" + */ + flags |= CCF_V | (env->cc_dest & (CCF_Z|CCF_N)); + } else { + if (quot == 0) { + flags |= CCF_Z; + } else if ((int16_t)quot < 0) { + flags |= CCF_N; + } + } + env->div1 = quot; env->div2 = rem; env->cc_dest = flags; @@ -220,12 +227,19 @@ void HELPER(divs)(CPUM68KState *env, uint32_t word) quot = num / den; rem = num % den; flags = 0; - if (word && quot != (int16_t)quot) - flags |= CCF_V; - if (quot == 0) - flags |= CCF_Z; - else if (quot < 0) - flags |= CCF_N; + if (word && quot != (int16_t)quot) { + /* real 68040 keep Z and N on overflow, + * whereas documentation says "undefined" + */ + flags |= CCF_V | (env->cc_dest & (CCF_Z|CCF_N)); + } else { + if (quot == 0) { + flags |= CCF_Z; + } else if ((int16_t)quot < 0) { + flags |= CCF_N; + } + } + env->div1 = quot; env->div2 = rem; env->cc_dest = flags; -- 2.4.3