1
0
mirror of https://github.com/sethm/symon.git synced 2024-12-27 19:30:03 +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:
Seth Morabito 2023-11-10 09:11:24 -08:00
parent 5e56627f32
commit 0c026e38dd
5 changed files with 18 additions and 10 deletions

View File

@ -227,6 +227,7 @@ to specify machine type and CPU type. The options are:
- `-machine simple`: Use the **Simple** machine type by default.
- `-machine beneater`: Use the **BenEater** machine type by default.
- `-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

View File

@ -53,6 +53,7 @@ public class Main {
options.addOption(new Option("m", "machine", true, "Specify machine 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("b", "brk", false, "Halt on BRK"));
CommandLineParser parser = new DefaultParser();
@ -60,6 +61,7 @@ public class Main {
CommandLine line = parser.parse(options, args);
InstructionTable.CpuBehavior cpuBehavior = null;
String romFile = null;
boolean haltOnBreak = false;
if (line.hasOption("machine")) {
String machine = line.getOptionValue("machine").toLowerCase(Locale.ENGLISH);
@ -104,6 +106,10 @@ public class Main {
romFile = line.getOptionValue("rom");
}
if (line.hasOption("brk")) {
haltOnBreak = true;
}
while (true) {
if (machineClass == null) {
Object[] possibilities = {"Symon", "Multicomp", "Simple", "BenEater"};
@ -132,7 +138,7 @@ public class Main {
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() {
@Override

View File

@ -29,8 +29,6 @@ public interface Preferences {
int DEFAULT_PROGRAM_LOAD_ADDRESS = 0x0300;
boolean DEFAULT_HALT_ON_BREAK = true;
JDialog getDialog();
int getProgramStartAddress();

View File

@ -126,6 +126,8 @@ public class Simulator {
private MainCommand command = MainCommand.NONE;
private boolean haltOnBreak;
public enum MainCommand {
NONE,
SELECTMACHINE
@ -137,16 +139,17 @@ public class Simulator {
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
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.machine = (Machine) machineClass.getConstructors()[0].newInstance(romFile);
this.machine.getCpu().setBehavior(cpuType);
// Initialize final fields in the constructor.
this.traceLog = new TraceLog();
this.memoryWindow = new MemoryWindow(machine.getBus());
@ -176,7 +179,7 @@ public class Simulator {
// File Chooser
fileChooser = new JFileChooser(System.getProperty("user.dir"));
preferences = new PreferencesDialog(mainWindow, true);
preferences = new PreferencesDialog(mainWindow, true, haltOnBreak);
// Panel for Console and Buttons
JPanel consoleContainer = new JPanel();

View File

@ -42,11 +42,11 @@ public class PreferencesDialog extends Observable implements Preferences {
private JTextField programLoadAddressField;
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.haltOnBreak = haltOnBreak;
createUi();
updateUi();
}