From: Joakim E. <jo...@us...> - 2011-05-01 10:19:42
|
The branch "master" has been updated via 40dca89e4d363c04754b05ed4a26d348a5b03e5f (commit) from f9cd90083823f56890f102e5e22af72b8a38e289 (commit) Changed paths: M se/sics/mspsim/core/MSP430Core.java M se/sics/mspsim/core/USARTSource.java M se/sics/mspsim/core/USCI.java - Log ----------------------------------------------------------------- commit 40dca89e4d363c04754b05ed4a26d348a5b03e5f Author: Joakim Eriksson <jo...@si...> Date: Sun May 1 12:19:02 2011 +0200 fixed destination handling for indexed mode to work below and above 64KB diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 575ecc2..d121aa5 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -988,6 +988,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { op = instruction >> 12; int sp = 0; int sr = 0; + int rval = 0; /* register value */ boolean word = (instruction & 0x40) == 0; // Destination vars @@ -1059,8 +1060,20 @@ public boolean emulateOP(long maxCycles) throws EmulationException { break; case AM_INDEX: // TODO: needs to handle if SR is used! - dstAddress = readRegisterCG(dstRegister, ad) + read(pc, MODE_WORD); -// memory[pc] + (memory[pc + 1] << 8); + rval = readRegisterCG(dstRegister, ad); + + /* Support for MSP430X and below / above 64 KB */ + /* if register is pointing to <64KB then it needs to be truncated to below 64 */ + if (rval < 0xffff) { + dstAddress = (rval + read(pc, MODE_WORD)) & 0xffff; + } else { + dstAddress = read(pc, MODE_WORD); + if ((dstAddress & 0x8000) > 0) { + dstAddress |= 0xf0000; + } + dstAddress += rval; + dstAddress &= 0xfffff; + } // When is PC incremented - assuming immediately after "read"? pc += 2; @@ -1300,6 +1313,8 @@ public boolean emulateOP(long maxCycles) throws EmulationException { srcAddress = readRegisterCG(srcRegister, as) + read(pc, MODE_WORD); // memory[pc] + (memory[pc + 1] << 8); // When is PC incremented - assuming immediately after "read"? + + incRegister(PC, 2); cycles += dstRegMode ? 3 : 6; break; @@ -1344,8 +1359,19 @@ public boolean emulateOP(long maxCycles) throws EmulationException { dstAddress = read(pc, MODE_WORD); //memory[pc] + (memory[pc + 1] << 8); } else { // CG here - probably not!??? - dstAddress = readRegister(dstRegister) + read(pc, MODE_WORD); -// + memory[pc] + (memory[pc + 1] << 8); + rval = readRegister(dstRegister); + /* Support for MSP430X and below / above 64 KB */ + /* if register is pointing to <64KB then it needs to be truncated to below 64 */ + if (rval < 0xffff) { + dstAddress = (rval + read(pc, MODE_WORD)) & 0xffff; + } else { + dstAddress = read(pc, MODE_WORD); + if ((dstAddress & 0x8000) > 0) { + dstAddress |= 0xf0000; + } + dstAddress += rval; + dstAddress &= 0xfffff; + } } if (op != MOV) diff --git a/se/sics/mspsim/core/USARTSource.java b/se/sics/mspsim/core/USARTSource.java old mode 100755 new mode 100644 diff --git a/se/sics/mspsim/core/USCI.java b/se/sics/mspsim/core/USCI.java old mode 100755 new mode 100644 ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/MSP430Core.java | 34 ++++++++++++++++++++++++++++++---- 1 files changed, 30 insertions(+), 4 deletions(-) mode change 100755 => 100644 se/sics/mspsim/core/USARTSource.java mode change 100755 => 100644 se/sics/mspsim/core/USCI.java hooks/post-receive -- mspsim |