mirror of
https://github.com/sethm/symon.git
synced 2024-12-28 11:30:51 +00:00
By default, do not halt on BRK (#14)
This change introduces a new command line flag, '-b', that cause the simulator to halt on the `BRK` instruction. By default, however, the simulator will no longer halt on `BRK`. As before, this behavior can be toggled in the preferences at run-time.
This commit is contained in:
parent
5e56627f32
commit
0c026e38dd
@ -227,6 +227,7 @@ to specify machine type and CPU type. The options are:
|
|||||||
- `-machine simple`: Use the **Simple** machine type by default.
|
- `-machine simple`: Use the **Simple** machine type by default.
|
||||||
- `-machine beneater`: Use the **BenEater** machine type by default.
|
- `-machine beneater`: Use the **BenEater** machine type by default.
|
||||||
- `-rom <file>`: Use the specified file as the ROM image.
|
- `-rom <file>`: Use the specified file as the ROM image.
|
||||||
|
- `-brk`: Halt the simulator on a BRK instruction (default is to continue)
|
||||||
|
|
||||||
### 4.2 ROM images
|
### 4.2 ROM images
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ public class Main {
|
|||||||
options.addOption(new Option("m", "machine", true, "Specify machine type."));
|
options.addOption(new Option("m", "machine", true, "Specify machine type."));
|
||||||
options.addOption(new Option("c", "cpu", true, "Specify CPU type."));
|
options.addOption(new Option("c", "cpu", true, "Specify CPU type."));
|
||||||
options.addOption(new Option("r", "rom", true, "Specify ROM file."));
|
options.addOption(new Option("r", "rom", true, "Specify ROM file."));
|
||||||
|
options.addOption(new Option("b", "brk", false, "Halt on BRK"));
|
||||||
|
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ public class Main {
|
|||||||
CommandLine line = parser.parse(options, args);
|
CommandLine line = parser.parse(options, args);
|
||||||
InstructionTable.CpuBehavior cpuBehavior = null;
|
InstructionTable.CpuBehavior cpuBehavior = null;
|
||||||
String romFile = null;
|
String romFile = null;
|
||||||
|
boolean haltOnBreak = false;
|
||||||
|
|
||||||
if (line.hasOption("machine")) {
|
if (line.hasOption("machine")) {
|
||||||
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
|
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
|
||||||
@ -104,6 +106,10 @@ public class Main {
|
|||||||
romFile = line.getOptionValue("rom");
|
romFile = line.getOptionValue("rom");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.hasOption("brk")) {
|
||||||
|
haltOnBreak = true;
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (machineClass == null) {
|
if (machineClass == null) {
|
||||||
Object[] possibilities = {"Symon", "Multicomp", "Simple", "BenEater"};
|
Object[] possibilities = {"Symon", "Multicomp", "Simple", "BenEater"};
|
||||||
@ -132,7 +138,7 @@ public class Main {
|
|||||||
cpuBehavior = InstructionTable.CpuBehavior.NMOS_6502;
|
cpuBehavior = InstructionTable.CpuBehavior.NMOS_6502;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Simulator simulator = new Simulator(machineClass, cpuBehavior, romFile);
|
final Simulator simulator = new Simulator(machineClass, cpuBehavior, romFile, haltOnBreak);
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,8 +29,6 @@ public interface Preferences {
|
|||||||
|
|
||||||
int DEFAULT_PROGRAM_LOAD_ADDRESS = 0x0300;
|
int DEFAULT_PROGRAM_LOAD_ADDRESS = 0x0300;
|
||||||
|
|
||||||
boolean DEFAULT_HALT_ON_BREAK = true;
|
|
||||||
|
|
||||||
JDialog getDialog();
|
JDialog getDialog();
|
||||||
|
|
||||||
int getProgramStartAddress();
|
int getProgramStartAddress();
|
||||||
|
@ -126,6 +126,8 @@ public class Simulator {
|
|||||||
|
|
||||||
private MainCommand command = MainCommand.NONE;
|
private MainCommand command = MainCommand.NONE;
|
||||||
|
|
||||||
|
private boolean haltOnBreak;
|
||||||
|
|
||||||
public enum MainCommand {
|
public enum MainCommand {
|
||||||
NONE,
|
NONE,
|
||||||
SELECTMACHINE
|
SELECTMACHINE
|
||||||
@ -137,16 +139,17 @@ public class Simulator {
|
|||||||
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
|
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
|
||||||
|
|
||||||
public Simulator(Class machineClass) throws Exception {
|
public Simulator(Class machineClass) throws Exception {
|
||||||
this(machineClass, InstructionTable.CpuBehavior.NMOS_6502, null);
|
this(machineClass, InstructionTable.CpuBehavior.NMOS_6502, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Simulator(Class machineClass, InstructionTable.CpuBehavior cpuType, String romFile) throws Exception {
|
public Simulator(Class machineClass, InstructionTable.CpuBehavior cpuType,
|
||||||
|
String romFile, boolean haltOnBreak) throws Exception {
|
||||||
|
this.haltOnBreak = haltOnBreak;
|
||||||
this.breakpoints = new Breakpoints(this);
|
this.breakpoints = new Breakpoints(this);
|
||||||
|
|
||||||
this.machine = (Machine) machineClass.getConstructors()[0].newInstance(romFile);
|
this.machine = (Machine) machineClass.getConstructors()[0].newInstance(romFile);
|
||||||
this.machine.getCpu().setBehavior(cpuType);
|
this.machine.getCpu().setBehavior(cpuType);
|
||||||
|
|
||||||
|
|
||||||
// Initialize final fields in the constructor.
|
// Initialize final fields in the constructor.
|
||||||
this.traceLog = new TraceLog();
|
this.traceLog = new TraceLog();
|
||||||
this.memoryWindow = new MemoryWindow(machine.getBus());
|
this.memoryWindow = new MemoryWindow(machine.getBus());
|
||||||
@ -176,7 +179,7 @@ public class Simulator {
|
|||||||
|
|
||||||
// File Chooser
|
// File Chooser
|
||||||
fileChooser = new JFileChooser(System.getProperty("user.dir"));
|
fileChooser = new JFileChooser(System.getProperty("user.dir"));
|
||||||
preferences = new PreferencesDialog(mainWindow, true);
|
preferences = new PreferencesDialog(mainWindow, true, haltOnBreak);
|
||||||
|
|
||||||
// Panel for Console and Buttons
|
// Panel for Console and Buttons
|
||||||
JPanel consoleContainer = new JPanel();
|
JPanel consoleContainer = new JPanel();
|
||||||
|
@ -42,11 +42,11 @@ public class PreferencesDialog extends Observable implements Preferences {
|
|||||||
private JTextField programLoadAddressField;
|
private JTextField programLoadAddressField;
|
||||||
|
|
||||||
private int programLoadAddress = DEFAULT_PROGRAM_LOAD_ADDRESS;
|
private int programLoadAddress = DEFAULT_PROGRAM_LOAD_ADDRESS;
|
||||||
private boolean haltOnBreak = DEFAULT_HALT_ON_BREAK;
|
private boolean haltOnBreak;
|
||||||
|
|
||||||
public PreferencesDialog(Frame parent, boolean modal) {
|
public PreferencesDialog(Frame parent, boolean modal, boolean haltOnBreak) {
|
||||||
this.dialog = new JDialog(parent, modal);
|
this.dialog = new JDialog(parent, modal);
|
||||||
|
this.haltOnBreak = haltOnBreak;
|
||||||
createUi();
|
createUi();
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user