From: <jo...@us...> - 2008-12-02 18:12:04
|
Revision: 431 http://mspsim.svn.sourceforge.net/mspsim/?rev=431&view=rev Author: joxe Date: 2008-12-02 18:12:00 +0000 (Tue, 02 Dec 2008) Log Message: ----------- added printout when misaligned word writes/reads are performed Modified Paths: -------------- mspsim/scripts/autorun.sc mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/scripts/autorun.sc =================================================================== --- mspsim/scripts/autorun.sc 2008-11-26 12:07:51 UTC (rev 430) +++ mspsim/scripts/autorun.sc 2008-12-02 18:12:00 UTC (rev 431) @@ -3,4 +3,4 @@ #exec rm log.txt #log CC2420 >log.txt #printcalls >log.txt -start +#start Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-11-26 12:07:51 UTC (rev 430) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-02 18:12:00 UTC (rev 431) @@ -105,7 +105,7 @@ }; public static final String[] REGISTER_NAMES = { - "PC", "SP", "SR", "CG1", "CG2" + "PC", "SP", "SR", "CG1", "CG2" }; public static final int PC = 0; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-11-26 12:07:51 UTC (rev 430) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-02 18:12:00 UTC (rev 431) @@ -598,7 +598,11 @@ address &= 0xffff; val = memory[address] & 0xff; if (word) { - val |= (memory[(address + 1) & 0xffff] << 8); + val |= (memory[(address + 1) & 0xffff] << 8); + if ((address & 1) != 0) { + System.out.println("**** Illegal read - misaligned word from: " + + Utils.hex16(address) + " at " + Utils.hex16(reg[PC])); + } } } if (breakPoints[address] != null) { @@ -620,7 +624,11 @@ // TODO: add check for Flash / RAM! memory[dstAddress] = dst & 0xff; if (word) { - memory[dstAddress + 1] = (dst >> 8) & 0xff; + memory[dstAddress + 1] = (dst >> 8) & 0xff; + if ((dstAddress & 1) != 0) { + System.out.println("**** Illegal write - misaligned word to: " + + Utils.hex16(dstAddress) + " at " + Utils.hex16(reg[PC])); + } } } } @@ -785,6 +793,7 @@ cycles++; break; case AM_INDEX: + // TODO: needs to handle if SR is used! dstAddress = readRegisterCG(dstRegister, ad) + memory[pc] + (memory[pc + 1] << 8); @@ -812,12 +821,6 @@ } break; } -// case AM_IND_AUTOINC: -// dstAddress = readRegister(dstRegister); -// writeRegister(dstRegister, dstAddress + (word ? 2 : 1)); -// cycles += 3; -// break; -// } } @@ -1035,6 +1038,7 @@ // PC Could have changed above! pc = readRegister(PC); if (dstRegister == 2) { + /* absolute mode */ dstAddress = memory[pc] + (memory[pc + 1] << 8); } else { // CG here??? @@ -1112,8 +1116,8 @@ sr = readRegister(SR); sr = (sr & ~(CARRY | OVERFLOW)) | (dst >= src ? CARRY : 0); - tmp = dst - src; - + tmp = (dst - src); + if (((src ^ tmp) & b) == 0 && (((src ^ dst) & b) != 0)) { sr |= OVERFLOW; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |