From patchwork Tue Jun 3 08:00:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 1258 Received: (qmail 17797 invoked by alias); 3 Jun 2014 08:00:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17782 invoked by uid 89); 3 Jun 2014 08:00:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jun 2014 08:00:28 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5380QD4028733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 3 Jun 2014 04:00:26 -0400 Received: from littlehelper.redhat.com (vpn1-6-66.ams2.redhat.com [10.36.6.66]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5380OMw032338 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO) for ; Tue, 3 Jun 2014 04:00:25 -0400 From: Nick Clifton To: gdb-patches@sourceware.org Subject: Commit: MSP430: Fix bug in simulation of hardware multiplies Date: Tue, 03 Jun 2014 09:00:23 +0100 Message-ID: <87mwdu1kyw.fsf@redhat.com> MIME-Version: 1.0 Hi Guys, I am checking in the patch below to fix a bug in the simulation of MSP430 hardware multiplies. The problem was that the result values were not being distributed into all of the result variables, so it was possible to perform a multiplication operation, switch to a new multiplication mode and then fail to read back the result of the just completed operation. Cheers Nick sim/msp430/ChangeLog 2014-06-03 Nick Clifton * msp430-sim.c (get_op): Handle reads of low result register when in MAC mode. (put_op): Copy MAC result into result words. Handle writes to the low result register. diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index 2dcbae3..7812868 100644 --- a/sim/msp430/msp430-sim.c +++ b/sim/msp430/msp430-sim.c @@ -413,16 +413,24 @@ get_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n) switch (addr) { case 0x13A: - rv = zero_ext (hwmult_result, 16); + switch (hwmult_type) + { + case UNSIGN_MAC_32: + case UNSIGN_32: rv = zero_ext (hwmult_result, 16); break; + case SIGN_MAC_32: + case SIGN_32: rv = sign_ext (hwmult_signed_result, 16); break; + } break; case 0x13C: switch (hwmult_type) { + case UNSIGN_MAC_32: case UNSIGN_32: rv = zero_ext (hwmult_result >> 16, 16); break; + case SIGN_MAC_32: case SIGN_32: rv = sign_ext (hwmult_signed_result >> 16, 16); break; @@ -599,7 +607,8 @@ put_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n, int val) case UNSIGN_MAC_32: hwmult_accumulator += hwmult_op1 * hwmult_op2; hwmult_signed_accumulator += hwmult_op1 * hwmult_op2; - hwmult_result = hwmult_signed_result = 0; + hwmult_result = hwmult_accumulator; + hwmult_signed_result = hwmult_signed_accumulator; break; case SIGN_MAC_32: @@ -607,11 +616,29 @@ put_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n, int val) b = sign_ext (hwmult_op2, 16); hwmult_accumulator += a * b; hwmult_signed_accumulator += a * b; - hwmult_result = hwmult_signed_result = 0; + hwmult_result = hwmult_accumulator; + hwmult_signed_result = hwmult_signed_accumulator; break; } break; + case 0x13a: + /* Copy into LOW result... */ + switch (hwmult_type) + { + case UNSIGN_MAC_32: + case UNSIGN_32: + hwmult_accumulator = hwmult_result = zero_ext (val, 16); + hwmult_signed_accumulator = sign_ext (val, 16); + break; + case SIGN_MAC_32: + case SIGN_32: + hwmult_signed_accumulator = hwmult_result = sign_ext (val, 16); + hwmult_accumulator = zero_ext (val, 16); + break; + } + break; + case 0x140: hw32mult_op1 = val; hw32mult_type = UNSIGN_64; break; case 0x142: hw32mult_op1 = (hw32mult_op1 & 0xFFFF) | (val << 16); break; case 0x144: hw32mult_op1 = val; hw32mult_type = SIGN_64; break;