diff --git a/Makefile b/Makefile
index 8bbeb07..4891da8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
# Makefile for mspsim
#
# Needed stuff in the PATH:
-# java, javac (JDK 1.6 or newer)
+# java, javac (JDK 1.7 or newer)
#
# Under MS-DOS/Windows
# A GNU compatible Make (for example Cygwin's)
@@ -46,7 +46,7 @@ SPACE := ${EMPTY} ${EMPTY}
LIBS := ${wildcard lib/*.jar}
BUILD := build
CLASSPATH=${subst ${SPACE},${SEPARATOR},$(BUILD)/ ${LIBS}}
-CCARGS=-deprecation -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
+CCARGS=-deprecation -Xlint:unchecked -source 1.7 -target 1.7 -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
JAVAARGS=-classpath "${CLASSPATH}"
@@ -196,3 +196,6 @@ $(BUILD)/%.class : %.java $(BUILD)
clean:
-$(RM) -r $(BUILD)
+
+distclean: clean
+ -$(RM) -f $(JARFILE)
diff --git a/README.txt b/README.txt
index 015c8ba..5483169 100644
--- a/README.txt
+++ b/README.txt
@@ -7,9 +7,8 @@ some tools for monitoring stack, setting breakpoints, and profiling.
* System requirements
-You need a recent Java to run MSPSim. Java SE 1.5 or newer is
-recommended. The current version of MSPSim also requires make for
-compiling.
+You need a recent Java to run MSPSim. Java SE 1.7 or newer is recommended.
+The current version of MSPSim also requires make or ant for compiling.
* Building MSPSim
@@ -60,4 +59,4 @@ Run the default example on the Sky node emulator by typing:
- currently the emulator runs as if it can use all memory as RAM
(e.g. flash writes, etc not supported)
- no DMA implementation
-- timer system not 100% emulated
\ No newline at end of file
+- timer system not 100% emulated
diff --git a/build.xml b/build.xml
index be31c78..b50c524 100644
--- a/build.xml
+++ b/build.xml
@@ -8,6 +8,8 @@
+
+
@@ -23,8 +25,12 @@
-
+
+
+
+
+
diff --git a/se/sics/mspsim/cli/CommandHandler.java b/se/sics/mspsim/cli/CommandHandler.java
index 22f5122..f8a44ca 100644
--- a/se/sics/mspsim/cli/CommandHandler.java
+++ b/se/sics/mspsim/cli/CommandHandler.java
@@ -4,7 +4,6 @@ import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
-
import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.util.ActiveComponent;
import se.sics.mspsim.util.ComponentRegistry;
@@ -32,7 +31,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
private MapTable getMapTable() {
if (mapTable == null && registry != null) {
- mapTable = (MapTable) registry.getComponent(MapTable.class);
+ mapTable = registry.getComponent(MapTable.class);
}
return mapTable;
}
@@ -42,6 +41,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
commands.put(cmd, command);
}
+ @SuppressWarnings("resource")
public int executeCommand(String commandLine, CommandContext context) {
String[][] parts;
final PrintStream cOut = context == null ? this.out : context.out;
diff --git a/se/sics/mspsim/core/Chip.java b/se/sics/mspsim/core/Chip.java
index e23901c..ed91697 100644
--- a/se/sics/mspsim/core/Chip.java
+++ b/se/sics/mspsim/core/Chip.java
@@ -35,8 +35,6 @@
* Created : 17 jan 2008
*/
package se.sics.mspsim.core;
-import java.io.PrintStream;
-
import se.sics.mspsim.core.EmulationLogger.WarningType;
import se.sics.mspsim.util.ArrayUtils;
@@ -63,7 +61,6 @@ public abstract class Chip implements Loggable, EventSource {
private int mode;
private int chipState;
protected EmulationLogger logger;
- private PrintStream log;
protected boolean DEBUG = false;
protected int logLevel;
diff --git a/se/sics/mspsim/core/MSP430.java b/se/sics/mspsim/core/MSP430.java
index fe99de1..15dc730 100644
--- a/se/sics/mspsim/core/MSP430.java
+++ b/se/sics/mspsim/core/MSP430.java
@@ -146,7 +146,8 @@ public class MSP430 extends MSP430Core {
isStopping = isBreaking = false;
}
- public long step() throws EmulationException {
+ /* Use stepInstructions or stepMicros instead */
+ @Deprecated public long step() throws EmulationException {
return stepMicros(1, 1);
}
@@ -156,16 +157,18 @@ public class MSP430 extends MSP430Core {
}
setRunning(true);
try {
- while (count-- > 0 && !isStopping) {
+ while (count > 0 && !isStopping) {
int pc = emulateOP(-1);
if (pc >= 0) {
+ count--;
if (execCounter != null) {
execCounter[pc]++;
}
if (trace != null) {
trace[tracePos++] = pc;
- if (tracePos >= trace.length)
- tracePos = 0;
+ if (tracePos >= trace.length) {
+ tracePos = 0;
+ }
}
// -------------------------------------------------------------------
diff --git a/se/sics/mspsim/emulink/EmuLink.java b/se/sics/mspsim/emulink/EmuLink.java
index 2dd042f..155af60 100755
--- a/se/sics/mspsim/emulink/EmuLink.java
+++ b/se/sics/mspsim/emulink/EmuLink.java
@@ -324,9 +324,8 @@ public class EmuLink {
}
}
- public void run() throws IOException {
- try {
- ServerSocket serverSocket = new ServerSocket(8000);
+ public void run() {
+ try (ServerSocket serverSocket = new ServerSocket(8000)) {
while(true) {
@@ -356,7 +355,7 @@ public class EmuLink {
}
}
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) {
EmuLink el = new EmuLink();
el.run();
}
diff --git a/se/sics/mspsim/platform/GenericNode.java b/se/sics/mspsim/platform/GenericNode.java
index f41566a..f566b9a 100644
--- a/se/sics/mspsim/platform/GenericNode.java
+++ b/se/sics/mspsim/platform/GenericNode.java
@@ -41,9 +41,7 @@ import java.io.IOException;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.net.URL;
-
import javax.swing.JFrame;
-
import se.sics.mspsim.cli.CommandHandler;
import se.sics.mspsim.cli.DebugCommands;
import se.sics.mspsim.cli.FileCommands;
@@ -54,7 +52,6 @@ import se.sics.mspsim.cli.StreamCommandHandler;
import se.sics.mspsim.cli.WindowCommands;
import se.sics.mspsim.core.Chip;
import se.sics.mspsim.core.EmulationException;
-import se.sics.mspsim.core.EmulationLogger;
import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.core.MSP430Config;
import se.sics.mspsim.core.MSP430Constants;
@@ -67,7 +64,6 @@ import se.sics.mspsim.ui.WindowUtils;
import se.sics.mspsim.util.ArgumentManager;
import se.sics.mspsim.util.ComponentRegistry;
import se.sics.mspsim.util.ConfigManager;
-import se.sics.mspsim.util.DefaultEmulationLogger;
import se.sics.mspsim.util.ELF;
import se.sics.mspsim.util.IHexReader;
import se.sics.mspsim.util.MapTable;
@@ -276,11 +272,9 @@ public abstract class GenericNode extends Chip implements Runnable {
public void stop() {
cpu.stop();
}
-
+
public void step() throws EmulationException {
- if (!cpu.isRunning()) {
- cpu.step();
- }
+ step(1);
}
// A step that will break out of breakpoints!
diff --git a/se/sics/mspsim/ui/DebugUI.java b/se/sics/mspsim/ui/DebugUI.java
index 98e601d..a8b96e5 100644
--- a/se/sics/mspsim/ui/DebugUI.java
+++ b/se/sics/mspsim/ui/DebugUI.java
@@ -47,19 +47,19 @@ import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
-
-import se.sics.mspsim.core.*;
+import se.sics.mspsim.core.DbgInstruction;
+import se.sics.mspsim.core.DisAsm;
+import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.util.Utils;
public class DebugUI extends JPanel {
private static final long serialVersionUID = 2123628878332126912L;
- private JList disList;
+ private JList disList;
+ private DbgListModel listModel;
private JLabel[] regsLabel;
private MSP430 cpu;
- private DbgListModel listModel;
- private int currentAddress = 0;
private DisAsm disAsm;
@@ -76,7 +76,8 @@ public class DebugUI extends JPanel {
this.cpu = cpu;
disAsm = cpu.getDisAsm();
- disList = new JList(listModel = new DbgListModel());
+ listModel = new DbgListModel();
+ disList = new JList(listModel);
disList.setFont(new Font("courier", 0, 12));
disList.setCellRenderer(new MyCellRenderer());
disList.setPreferredSize(new Dimension(500, 350));
@@ -102,7 +103,7 @@ public class DebugUI extends JPanel {
repaint();
}
- private class DbgListModel extends AbstractListModel {
+ private class DbgListModel extends AbstractListModel {
private static final long serialVersionUID = -2856626511548201481L;
int startPos = -1;
@@ -111,44 +112,36 @@ public class DebugUI extends JPanel {
DbgInstruction[] instructions = new DbgInstruction[size];
- // 64K Dbg instructions...
- // private DbgInstruction[] instrs = new DbgInstruction[0x10000];
-
- public void setCurrentAddress(int address) {
- startPos = address;
- }
-
// -------------------------------------------------------------------
// ListAPI
// -------------------------------------------------------------------
+ @Override
public int getSize() {
return size;
}
private void checkPC() {
- int pc = cpu.reg[MSP430Core.PC];
+ int pc = cpu.getPC();
if (pc < startPos || pc > endPos) {
startPos = pc;
// recalculate index!!! with PC at the top of the "page"
int currentPos = pc;
- DbgInstruction inst;
for (int i = 0, n = size; i < n; i++) {
- if (cpu.getExecCount(currentPos) != 0 || true) {
- inst = disAsm.getDbgInstruction(currentPos, cpu);
- inst.setPos(currentPos);
- currentPos += inst.getSize();
- } else {
- inst = new DbgInstruction();
- inst.setASMLine(" " + Utils.hex16(currentPos) + " " +
- Utils.hex8(cpu.memory[currentPos]) + " " +
- Utils.hex8(cpu.memory[currentPos + 1]) +
- " .word " + Utils.hex8(cpu.memory[currentPos]) +
- Utils.hex8(cpu.memory[currentPos + 1]));
- inst.setPos(currentPos);
- currentPos += 2;
- }
- instructions[i] = inst;
+// if (cpu.getExecCount(currentPos) == 0) {
+// inst = new DbgInstruction();
+// inst.setInstruction(cpu.memory[currentPos] + (cpu.memory[currentPos + 1] << 8), 2);
+// inst.setASMLine(" " + Utils.hex(currentPos, 4) + " " +
+// Utils.hex8(cpu.memory[currentPos]) + " " +
+// Utils.hex8(cpu.memory[currentPos + 1]) +
+// " .word " + Utils.hex8(cpu.memory[currentPos]) +
+// Utils.hex8(cpu.memory[currentPos + 1]));
+// } else {
+
+ DbgInstruction inst = disAsm.getDbgInstruction(currentPos, cpu);
+ inst.setPos(currentPos);
+ currentPos += inst.getSize();
+ instructions[i] = inst;
}
endPos = currentPos;
}
@@ -157,13 +150,14 @@ public class DebugUI extends JPanel {
// Should cache the current 20 (or size) instructions to get a faster
// version of this...
// And have a call to "update" instead...
- public Object getElementAt(int index) {
+ @Override
+ public DbgInstruction getElementAt(int index) {
checkPC();
return instructions[index];
}
}
- class MyCellRenderer extends JLabel implements ListCellRenderer {
+ class MyCellRenderer extends JLabel implements ListCellRenderer {
private static final long serialVersionUID = -2633138712695105181L;
@@ -171,36 +165,32 @@ public class DebugUI extends JPanel {
setOpaque(true);
}
+ @Override
public Component getListCellRendererComponent(
- JList list,
- Object value, // value to display
+ JList extends DbgInstruction> list,
+ DbgInstruction instruction, // instruct to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
{
String s;
int pos = 0;
- if (value == null) {
- s = "---";
+ if (instruction == null) {
+ s = "---";
} else {
- if (value instanceof DbgInstruction) {
- DbgInstruction i = (DbgInstruction) value;
- s = i.getASMLine(false);
- if (i.getFunction() != null) {
- s += "; " + i.getFunction();
- }
- pos = i.getPos();
+ pos = instruction.getPos();
+ s = instruction.getASMLine(false);
if (cpu.hasWatchPoint(pos)) {
s = "*B " + s;
} else {
s = " " + s;
}
- } else {
- s = value.toString();
- }
+ if (instruction.getFunction() != null) {
+ s += "; " + instruction.getFunction();
+ }
}
setText(s);
- if (pos == cpu.reg[MSP430Core.PC]) {
+ if (pos == cpu.getPC()) {
setBackground(Color.green);
} else {
if (isSelected) {