From bf4adb2c16ffd50d054fc8a6a536ce2b75c39745 Mon Sep 17 00:00:00 2001 From: joxe Date: Thu, 25 Oct 2007 12:21:58 +0000 Subject: [PATCH] fixed bug in BIT instruction git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@10 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 --- se/sics/mspsim/core/MSP430Core.java | 5 +++-- tests/cputest.c | 24 ++++++++---------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index ce1246d..c195763 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -862,11 +862,12 @@ public class MSP430Core implements MSP430Constants { case BIT: // BIT dst = src & dst; sr = readRegister(SR); + // Clear overflow and carry! + sr = sr & ~(CARRY | OVERFLOW); + // Set carry if result is non-zero! if (dst != 0) { sr |= CARRY; } - // Clear overflow! - sr &= ~OVERFLOW; writeRegister(SR, sr); break; case BIC: // BIC diff --git a/tests/cputest.c b/tests/cputest.c index 3ed9578..65b6294 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -169,24 +169,16 @@ static void testFunctions() { /*--------------------------------------------------------------------------*/ static void testModulo() { - int c,i; - c = 1; + int c; testCase("Modulo"); - do { - i = 13; - i = i % 14; -/* printf("(%d,%d,%d)\n",i, (i % 14), i==1); */ -/* printf("(%d,%d,%d)\n",i, (i % 14), i==1); */ - if (i < 0) printf("%d\n",i); - - - c = c + 1; - } while (c < 3); - -/* if((i % 5) == 0) { */ -/* assertTrue(i != 1); */ -/* } */ + for(c = 2; c >= 0; c--) { + if((c % 5) == 0) { + assertTrue(c != 1); + } + printf("(%d,%d,%d)\n", c, (c % 5), c==1); + printf("(%d,%d,%d)\n", c, (c % 5), c==1); + } } /*--------------------------------------------------------------------------*/