Whitespace and indentation canonicalization. That's what I get for using two editors.

This commit is contained in:
Seth J. Morabito committed 2008-12-27 21:09:47 -08:00
1 parent d54ad18b17
commit 8bcd8a4a75
18 files changed
+5240 -5241

No files matched your search

+126 -126
View File
@@ -9,136 +9,136 @@ import com.loomcom.symon.exceptions.*;
*/ */
public class Bus { public class Bus {
// By default, our bus starts at 0, and goes up to 64K // By default, our bus starts at 0, and goes up to 64K
private int startAddress = 0x0000; private int startAddress = 0x0000;
private int endAddress = 0xffff; private int endAddress = 0xffff;
// The CPU // The CPU
private Cpu cpu; private Cpu cpu;
// Ordered list of IO devices. // Ordered list of IO devices.
private SortedSet<Device> devices; private SortedSet<Device> devices;
public Bus(int size) { public Bus(int size) {
this(0, size - 1); this(0, size - 1);
} }
public Bus(int startAddress, int endAddress) { public Bus(int startAddress, int endAddress) {
this.devices = new TreeSet<Device>(); this.devices = new TreeSet<Device>();
this.startAddress = startAddress; this.startAddress = startAddress;
this.endAddress = endAddress; this.endAddress = endAddress;
} }
public int startAddress() { public int startAddress() {
return startAddress; return startAddress;
} }
public int endAddress() { public int endAddress() {
return endAddress; return endAddress;
} }
public void addDevice(Device device) public void addDevice(Device device)
throws MemoryRangeException { throws MemoryRangeException {
// Make sure there's no memory overlap. // Make sure there's no memory overlap.
MemoryRange memRange = device.getMemoryRange(); MemoryRange memRange = device.getMemoryRange();
for (Device d : devices) { for (Device d : devices) {
if (d.getMemoryRange().overlaps(memRange)) { if (d.getMemoryRange().overlaps(memRange)) {
throw new MemoryRangeException("The device being added " + throw new MemoryRangeException("The device being added " +
"overlaps with an existing " + "overlaps with an existing " +
"device."); "device.");
} }
}
// Add the device
device.setBus(this);
devices.add(device);
}
public void addCpu(Cpu cpu) {
cpu.setBus(this);
this.cpu = cpu;
}
/**
* Returns true if the memory map is full, i.e., there are no
* gaps between any IO devices. All memory locations map to some
* device.
*/
public boolean isComplete() {
// Empty maps cannot be complete.
if (devices.isEmpty()) { return false; }
// Loop over devices and ensure they are contiguous.
MemoryRange prev = null;
int i = 0;
int length = devices.size();
for (Device d : devices) {
MemoryRange cur = d.getMemoryRange();
if (i == 0) {
// If the first entry doesn't start at 'startAddress', return false.
if (cur.startAddress() != startAddress) { return false; }
}
if (prev != null && i < length - 1) {
// Otherwise, compare previous map's end against this map's
// endAddress. They must be adjacent!
if (cur.startAddress() - 1 != prev.endAddress()) {
return false;
}
}
if (i == length - 1) {
// If the last entry doesn't end at endAddress, return false;
if (cur.endAddress() != endAddress) { return false; }
}
i++;
prev = cur;
}
// Must be complete.
return true;
}
public int read(int address) {
for (Device d : devices) {
MemoryRange range = d.getMemoryRange();
if (range.includes(address)) {
// Compute offset into this device's address space.
int devAddr = address - range.startAddress();
return d.read(devAddr);
}
}
// TODO: Raise access error.
throw new RuntimeException("Read failed! Device not found.");
}
public void write(int address, int value) {
for (Device d : devices) {
MemoryRange range = d.getMemoryRange();
if (range.includes(address)) {
// Compute offset into this device's address space.
int devAddr = address - range.startAddress();
d.write(devAddr, value);
return;
}
}
// TODO: Raise access error.
throw new RuntimeException("Write failed! Device not found.");
}
public SortedSet<Device> getDevices() {
// Expose a copy of the device list, not the original
return new TreeSet<Device>(devices);
}
public Cpu getCpu() {
return cpu;
}
public void loadProgram(int... program) {
int address = getCpu().getProgramCounter();
int i = 0;
for (int d : program) {
write(address + i++, d);
}
} }
// Add the device
device.setBus(this);
devices.add(device);
}
public void addCpu(Cpu cpu) {
cpu.setBus(this);
this.cpu = cpu;
}
/**
* Returns true if the memory map is full, i.e., there are no
* gaps between any IO devices. All memory locations map to some
* device.
*/
public boolean isComplete() {
// Empty maps cannot be complete.
if (devices.isEmpty()) { return false; }
// Loop over devices and ensure they are contiguous.
MemoryRange prev = null;
int i = 0;
int length = devices.size();
for (Device d : devices) {
MemoryRange cur = d.getMemoryRange();
if (i == 0) {
// If the first entry doesn't start at 'startAddress', return false.
if (cur.startAddress() != startAddress) { return false; }
}
if (prev != null && i < length - 1) {
// Otherwise, compare previous map's end against this map's
// endAddress. They must be adjacent!
if (cur.startAddress() - 1 != prev.endAddress()) {
return false;
}
}
if (i == length - 1) {
// If the last entry doesn't end at endAddress, return false;
if (cur.endAddress() != endAddress) { return false; }
}
i++;
prev = cur;
}
// Must be complete.
return true;
}
public int read(int address) {
for (Device d : devices) {
MemoryRange range = d.getMemoryRange();
if (range.includes(address)) {
// Compute offset into this device's address space.
int devAddr = address - range.startAddress();
return d.read(devAddr);
}
}
// TODO: Raise access error.
throw new RuntimeException("Read failed! Device not found.");
}
public void write(int address, int value) {
for (Device d : devices) {
MemoryRange range = d.getMemoryRange();
if (range.includes(address)) {
// Compute offset into this device's address space.
int devAddr = address - range.startAddress();
d.write(devAddr, value);
return;
}
}
// TODO: Raise access error.
throw new RuntimeException("Write failed! Device not found.");
}
public SortedSet<Device> getDevices() {
// Expose a copy of the device list, not the original
return new TreeSet<Device>(devices);
}
public Cpu getCpu() {
return cpu;
}
public void loadProgram(int... program) {
int address = getCpu().getProgramCounter();
int i = 0;
for (int d : program) {
write(address + i++, d);
}
}
} }
@@ -4,69 +4,69 @@ import java.io.*;
public class CommandParser { public class CommandParser {
private BufferedReader in; private BufferedReader in;
private BufferedWriter out; private BufferedWriter out;
private Simulator simulator; private Simulator simulator;
public CommandParser(InputStream i, OutputStream o, Simulator s) { public CommandParser(InputStream i, OutputStream o, Simulator s) {
this.in = new BufferedReader(new InputStreamReader(i)); this.in = new BufferedReader(new InputStreamReader(i));
this.out = new BufferedWriter(new OutputStreamWriter(o)); this.out = new BufferedWriter(new OutputStreamWriter(o));
this.simulator = s; this.simulator = s;
} }
public void run() { public void run() {
try { try {
String command = null; String command = null;
greeting(); greeting();
prompt(); prompt();
while (!shouldQuit(command = readLine())) { while (!shouldQuit(command = readLine())) {
dispatch(command); dispatch(command);
prompt(); prompt();
} }
writeLine("\n\nGoodbye!"); writeLine("\n\nGoodbye!");
} catch (IOException ex) { } catch (IOException ex) {
System.err.println("Error: " + ex.toString()); System.err.println("Error: " + ex.toString());
System.exit(1); System.exit(1);
} }
} }
/** /**
* Dispatch the command. * Dispatch the command.
*/ */
public void dispatch(String command) throws IOException { public void dispatch(String command) throws IOException {
writeLine("You entered: " + command); writeLine("You entered: " + command);
} }
/******************************************************************* /*******************************************************************
* Private * Private
*******************************************************************/ *******************************************************************/
private void greeting() throws IOException { private void greeting() throws IOException {
writeLine("Welcome to the j6502 Simulator!"); writeLine("Welcome to the j6502 Simulator!");
} }
private void prompt() throws IOException { private void prompt() throws IOException {
out.write("j6502> "); out.write("j6502> ");
out.flush(); out.flush();
} }
private String readLine() throws IOException { private String readLine() throws IOException {
String line = in.readLine(); String line = in.readLine();
if (line == null) { return null; } if (line == null) { return null; }
return line.trim(); return line.trim();
} }
private void writeLine(String line) throws IOException { private void writeLine(String line) throws IOException {
out.write(line); out.write(line);
out.newLine(); out.newLine();
out.flush(); out.flush();
} }
/** /**
* Returns true if the line is a quit. * Returns true if the line is a quit.
*/ */
private boolean shouldQuit(String line) { private boolean shouldQuit(String line) {
return (line == null || "q".equals(line.toLowerCase())); return (line == null || "q".equals(line.toLowerCase()));
} }
} }
File diff suppressed because it is too large. Load diff
@@ -2,248 +2,248 @@ package com.loomcom.symon;
public interface InstructionTable { public interface InstructionTable {
/** /**
* Enumeration of Addressing Modes. * Enumeration of Addressing Modes.
*/ */
public enum Mode { public enum Mode {
ACC { ACC {
public String toString() { public String toString() {
return "Accumulator"; return "Accumulator";
} }
}, },
ABS { ABS {
public String toString() { public String toString() {
return "Absolute"; return "Absolute";
} }
}, },
ABX { ABX {
public String toString() { public String toString() {
return "Absolute, X-indexed"; return "Absolute, X-indexed";
} }
}, },
ABY { ABY {
public String toString() { public String toString() {
return "Absolute, Y-indexed"; return "Absolute, Y-indexed";
} }
}, },
IMM { IMM {
public String toString() { public String toString() {
return "Immediate"; return "Immediate";
} }
}, },
IMP { IMP {
public String toString() { public String toString() {
return "Implied"; return "Implied";
} }
}, },
IND { IND {
public String toString() { public String toString() {
return "Indirect"; return "Indirect";
} }
}, },
XIN { XIN {
public String toString() { public String toString() {
return "X-indexed Indirect"; return "X-indexed Indirect";
} }
}, },
INY { INY {
public String toString() { public String toString() {
return "Indirect, Y-indexedY"; return "Indirect, Y-indexedY";
} }
}, },
REL { REL {
public String toString() { public String toString() {
return "Relative"; return "Relative";
} }
}, },
ZPG { ZPG {
public String toString() { public String toString() {
return "Zeropage"; return "Zeropage";
} }
}, },
ZPX { ZPX {
public String toString() { public String toString() {
return "Zeropage, X-indexed"; return "Zeropage, X-indexed";
} }
}, },
ZPY { ZPY {
public String toString() { public String toString() {
return "Zeropage, Y-indexed"; return "Zeropage, Y-indexed";
} }
}, },
NUL { NUL {
public String toString() { public String toString() {
return "NULL"; return "NULL";
} }
} }
} }
// 6502 opcodes. No 65C02 opcodes implemented. // 6502 opcodes. No 65C02 opcodes implemented.
/** /**
* Instruction opcode names. * Instruction opcode names.
*/ */
public static final String[] opcodeNames = { public static final String[] opcodeNames = {
"BRK", "ORA", null, null, null, "ORA", "ASL", null, "BRK", "ORA", null, null, null, "ORA", "ASL", null,
"PHP", "ORA", "ASL", null, null, "ORA", "ASL", null, "PHP", "ORA", "ASL", null, null, "ORA", "ASL", null,
"BPL", "ORA", null, null, null, "ORA", "ASL", null, "BPL", "ORA", null, null, null, "ORA", "ASL", null,
"CLC", "ORA", null, null, null, "ORA", "ASL", null, "CLC", "ORA", null, null, null, "ORA", "ASL", null,
"JSR", "AND", null, null, "BIT", "AND", "ROL", null, "JSR", "AND", null, null, "BIT", "AND", "ROL", null,
"PLP", "AND", "ROL", null, "BIT", "AND", "ROL", null, "PLP", "AND", "ROL", null, "BIT", "AND", "ROL", null,
"BMI", "AND", null, null, null, "AND", "ROL", null, "BMI", "AND", null, null, null, "AND", "ROL", null,
"SEC", "AND", null, null, null, "AND", "ROL", null, "SEC", "AND", null, null, null, "AND", "ROL", null,
"RTI", "EOR", null, null, null, "EOR", "LSR", null, "RTI", "EOR", null, null, null, "EOR", "LSR", null,
"PHA", "EOR", "LSR", null, "JMP", "EOR", "LSR", null, "PHA", "EOR", "LSR", null, "JMP", "EOR", "LSR", null,
"BVC", "EOR", null, null, null, "EOR", "LSR", null, "BVC", "EOR", null, null, null, "EOR", "LSR", null,
"CLI", "EOR", null, null, null, "EOR", "LSR", null, "CLI", "EOR", null, null, null, "EOR", "LSR", null,
"RTS", "ADC", null, null, null, "ADC", "ROR", null, "RTS", "ADC", null, null, null, "ADC", "ROR", null,
"PLA", "ADC", "ROR", null, "JMP", "ADC", "ROR", null, "PLA", "ADC", "ROR", null, "JMP", "ADC", "ROR", null,
"BVS", "ADC", null, null, null, "ADC", "ROR", null, "BVS", "ADC", null, null, null, "ADC", "ROR", null,
"SEI", "ADC", null, null, null, "ADC", "ROR", null, "SEI", "ADC", null, null, null, "ADC", "ROR", null,
"BCS", "STA", null, null, "STY", "STA", "STX", null, "BCS", "STA", null, null, "STY", "STA", "STX", null,
"DEY", null, "TXA", null, "STY", "STA", "STX", null, "DEY", null, "TXA", null, "STY", "STA", "STX", null,
"BCC", "STA", null, null, "STY", "STA", "STX", null, "BCC", "STA", null, null, "STY", "STA", "STX", null,
"TYA", "STA", "TXS", null, null, "STA", null, null, "TYA", "STA", "TXS", null, null, "STA", null, null,
"LDY", "LDA", "LDX", null, "LDY", "LDA", "LDX", null, "LDY", "LDA", "LDX", null, "LDY", "LDA", "LDX", null,
"TAY", "LDA", "TAX", null, "LDY", "LDA", "LDX", null, "TAY", "LDA", "TAX", null, "LDY", "LDA", "LDX", null,
null, "LDA", null, null, "LDY", "LDA", "LDX", null, null, "LDA", null, null, "LDY", "LDA", "LDX", null,
"CLV", "LDA", "TSX", null, "LDY", "LDA", "LDX", null, "CLV", "LDA", "TSX", null, "LDY", "LDA", "LDX", null,
"CPY", "CMP", null, null, "CPY", "CMP", "DEC", null, "CPY", "CMP", null, null, "CPY", "CMP", "DEC", null,
"INY", "CMP", "DEX", null, "CPY", "CMP", "DEC", null, "INY", "CMP", "DEX", null, "CPY", "CMP", "DEC", null,
"BNE", "CMP", null, null, null, "CMP", "DEC", null, "BNE", "CMP", null, null, null, "CMP", "DEC", null,
"CLD", "CMP", null, null, null, "CMP", "DEC", null, "CLD", "CMP", null, null, null, "CMP", "DEC", null,
"CPX", "SBC", null, null, "CPX", "SBC", "INC", null, "CPX", "SBC", null, null, "CPX", "SBC", "INC", null,
"INX", "SBC", "NOP", null, "CPX", "SBC", "INC", null, "INX", "SBC", "NOP", null, "CPX", "SBC", "INC", null,
"BEQ", "SBC", null, null, null, "SBC", "INC", null, "BEQ", "SBC", null, null, null, "SBC", "INC", null,
"SED", "SBC", null, null, null, "SBC", "INC", null "SED", "SBC", null, null, null, "SBC", "INC", null
}; };
/** /**
* Instruction addressing modes. * Instruction addressing modes.
*/ */
public static final Mode[] instructionModes = { public static final Mode[] instructionModes = {
Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x00-0x03 Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x00-0x03
Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x04-0x07 Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x04-0x07
Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x08-0x0b Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x08-0x0b
Mode.NUL, Mode.ABS, Mode.ABS, Mode.NUL, // 0x0c-0x0f Mode.NUL, Mode.ABS, Mode.ABS, Mode.NUL, // 0x0c-0x0f
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x10-0x13 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x10-0x13
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x14-0x17 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x14-0x17
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x18-0x1b Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x18-0x1b
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x1c-0x1f Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x1c-0x1f
Mode.ABS, Mode.XIN, Mode.NUL, Mode.NUL, // 0x20-0x23 Mode.ABS, Mode.XIN, Mode.NUL, Mode.NUL, // 0x20-0x23
Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x24-0x27 Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x24-0x27
Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x28-0x2b Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x28-0x2b
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x2c-0x2f Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x2c-0x2f
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x30-0x33 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x30-0x33
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x34-0x37 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x34-0x37
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x38-0x3b Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x38-0x3b
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x3c-0x3f Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x3c-0x3f
Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x40-0x43 Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x40-0x43
Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x44-0x47 Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x44-0x47
Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x48-0x4b Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x48-0x4b
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x4c-0x4f Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x4c-0x4f
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x50-0x53 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x50-0x53
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x54-0x57 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x54-0x57
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x58-0x5b Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x58-0x5b
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x5c-0x5f Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x5c-0x5f
Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x60-0x63 Mode.IMP, Mode.XIN, Mode.NUL, Mode.NUL, // 0x60-0x63
Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x64-0x67 Mode.NUL, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x64-0x67
Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x68-0x6b Mode.IMP, Mode.IMM, Mode.ACC, Mode.NUL, // 0x68-0x6b
Mode.IND, Mode.ABS, Mode.ABS, Mode.NUL, // 0x6c-0x6f Mode.IND, Mode.ABS, Mode.ABS, Mode.NUL, // 0x6c-0x6f
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x70-0x73 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x70-0x73
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x74-0x77 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0x74-0x77
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x78-0x7b Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0x78-0x7b
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x7c-0x7f Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0x7c-0x7f
Mode.REL, Mode.XIN, Mode.NUL, Mode.NUL, // 0x80-0x83 Mode.REL, Mode.XIN, Mode.NUL, Mode.NUL, // 0x80-0x83
Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x84-0x87 Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0x84-0x87
Mode.IMP, Mode.NUL, Mode.IMP, Mode.NUL, // 0x88-0x8b Mode.IMP, Mode.NUL, Mode.IMP, Mode.NUL, // 0x88-0x8b
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x8c-0x8f Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0x8c-0x8f
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x90-0x93 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0x90-0x93
Mode.ZPX, Mode.ZPX, Mode.ZPY, Mode.NUL, // 0x94-0x97 Mode.ZPX, Mode.ZPX, Mode.ZPY, Mode.NUL, // 0x94-0x97
Mode.IMP, Mode.ABX, Mode.IMP, Mode.NUL, // 0x98-0x9b Mode.IMP, Mode.ABX, Mode.IMP, Mode.NUL, // 0x98-0x9b
Mode.NUL, Mode.ABY, Mode.NUL, Mode.NUL, // 0x9c-0x9f Mode.NUL, Mode.ABY, Mode.NUL, Mode.NUL, // 0x9c-0x9f
Mode.IMM, Mode.XIN, Mode.IMM, Mode.NUL, // 0xa0-0xa3 Mode.IMM, Mode.XIN, Mode.IMM, Mode.NUL, // 0xa0-0xa3
Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xa4-0xa7 Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xa4-0xa7
Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xa8-0xab Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xa8-0xab
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xac-0xaf Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xac-0xaf
Mode.NUL, Mode.INY, Mode.NUL, Mode.NUL, // 0xb0-0xb3 Mode.NUL, Mode.INY, Mode.NUL, Mode.NUL, // 0xb0-0xb3
Mode.ZPX, Mode.ZPX, Mode.ZPY, Mode.NUL, // 0xb4-0xb7 Mode.ZPX, Mode.ZPX, Mode.ZPY, Mode.NUL, // 0xb4-0xb7
Mode.IMP, Mode.ABX, Mode.IMP, Mode.NUL, // 0xb8-0xbb Mode.IMP, Mode.ABX, Mode.IMP, Mode.NUL, // 0xb8-0xbb
Mode.ABX, Mode.ABY, Mode.ABY, Mode.NUL, // 0xbc-0xbf Mode.ABX, Mode.ABY, Mode.ABY, Mode.NUL, // 0xbc-0xbf
Mode.IMM, Mode.XIN, Mode.NUL, Mode.NUL, // 0xc0-0xc3 Mode.IMM, Mode.XIN, Mode.NUL, Mode.NUL, // 0xc0-0xc3
Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xc4-0xc7 Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xc4-0xc7
Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xc8-0xcb Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xc8-0xcb
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xcc-0xcf Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xcc-0xcf
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0xd0-0xd3 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0xd0-0xd3
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0xd4-0xd7 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0xd4-0xd7
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0xd8-0xdb Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0xd8-0xdb
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0xdc-0xdf Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL, // 0xdc-0xdf
Mode.IMM, Mode.XIN, Mode.NUL, Mode.NUL, // 0xe0-0xe3 Mode.IMM, Mode.XIN, Mode.NUL, Mode.NUL, // 0xe0-0xe3
Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xe4-0xe7 Mode.ZPG, Mode.ZPG, Mode.ZPG, Mode.NUL, // 0xe4-0xe7
Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xe8-0xeb Mode.IMP, Mode.IMM, Mode.IMP, Mode.NUL, // 0xe8-0xeb
Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xec-0xef Mode.ABS, Mode.ABS, Mode.ABS, Mode.NUL, // 0xec-0xef
Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0xf0-0xf3 Mode.REL, Mode.INY, Mode.NUL, Mode.NUL, // 0xf0-0xf3
Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0xf4-0xf7 Mode.NUL, Mode.ZPX, Mode.ZPX, Mode.NUL, // 0xf4-0xf7
Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0xf8-0xfb Mode.IMP, Mode.ABY, Mode.NUL, Mode.NUL, // 0xf8-0xfb
Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL // 0xfc-0xff Mode.NUL, Mode.ABX, Mode.ABX, Mode.NUL // 0xfc-0xff
}; };
/** /**
* Size, in bytes, required for each instruction. * Size, in bytes, required for each instruction.
*/ */
public static final int[] instructionSizes = { public static final int[] instructionSizes = {
1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 0, 3, 3, 0, 1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 0, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0, 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0,
3, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 3, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0, 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0,
1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0, 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0,
1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 1, 2, 0, 0, 0, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0, 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0,
2, 2, 0, 0, 2, 2, 2, 0, 1, 0, 1, 0, 3, 3, 3, 0, 2, 2, 0, 0, 2, 2, 2, 0, 1, 0, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 0, 3, 0, 0, 2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 0, 3, 0, 0,
2, 2, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 2, 2, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
0, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0, 0, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0, 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0,
2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0, 2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0 2, 2, 0, 0, 0, 2, 2, 0, 1, 3, 0, 0, 0, 3, 3, 0
}; };
/** /**
* Number of clock cycles required for each instruction * Number of clock cycles required for each instruction
*/ */
public static final int[] instructionClocks = { public static final int[] instructionClocks = {
7, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 0, 4, 6, 0, 7, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 0, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
6, 6, 0, 0, 3, 3, 5, 0, 4, 2, 2, 0, 4, 4, 6, 0, 6, 6, 0, 0, 3, 3, 5, 0, 4, 2, 2, 0, 4, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
6, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 3, 4, 6, 0, 6, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 3, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
6, 6, 0, 0, 0, 3, 5, 0, 4, 2, 2, 0, 5, 4, 6, 0, 6, 6, 0, 0, 0, 3, 5, 0, 4, 2, 2, 0, 5, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
2, 6, 0, 0, 3, 3, 3, 0, 2, 0, 2, 0, 4, 4, 4, 0, 2, 6, 0, 0, 3, 3, 3, 0, 2, 0, 2, 0, 4, 4, 4, 0,
2, 6, 0, 0, 4, 4, 4, 0, 2, 5, 2, 0, 0, 5, 0, 0, 2, 6, 0, 0, 4, 4, 4, 0, 2, 5, 2, 0, 0, 5, 0, 0,
2, 6, 2, 0, 3, 3, 3, 0, 2, 2, 2, 0, 4, 4, 4, 0, 2, 6, 2, 0, 3, 3, 3, 0, 2, 2, 2, 0, 4, 4, 4, 0,
0, 5, 0, 0, 4, 4, 4, 0, 2, 4, 2, 0, 4, 4, 4, 0, 0, 5, 0, 0, 4, 4, 4, 0, 2, 4, 2, 0, 4, 4, 4, 0,
2, 6, 0, 0, 3, 3, 5, 0, 2, 2, 2, 0, 4, 4, 6, 0, 2, 6, 0, 0, 3, 3, 5, 0, 2, 2, 2, 0, 4, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
2, 6, 0, 0, 3, 3, 5, 0, 2, 2, 2, 0, 4, 4, 6, 0, 2, 6, 0, 0, 3, 3, 5, 0, 2, 2, 2, 0, 4, 4, 6, 0,
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0
}; };
} }
@@ -11,77 +11,77 @@ import com.loomcom.symon.exceptions.*;
*/ */
public class MemoryRange implements Comparable<MemoryRange> { public class MemoryRange implements Comparable<MemoryRange> {
/** The starting address of the memory range. */ /** The starting address of the memory range. */
public int startAddress; public int startAddress;
/** The ending address of the memory range. */ /** The ending address of the memory range. */
public int endAddress; public int endAddress;
public MemoryRange(int startAddress, int endAddress) public MemoryRange(int startAddress, int endAddress)
throws MemoryRangeException { throws MemoryRangeException {
if (startAddress < 0 || endAddress < 0) { if (startAddress < 0 || endAddress < 0) {
throw new MemoryRangeException("Addresses cannot be less than 0."); throw new MemoryRangeException("Addresses cannot be less than 0.");
} }
if (startAddress >= endAddress) { if (startAddress >= endAddress) {
throw new MemoryRangeException("End address must be greater " + throw new MemoryRangeException("End address must be greater " +
"than start address."); "than start address.");
} }
this.startAddress = startAddress; this.startAddress = startAddress;
this.endAddress = endAddress; this.endAddress = endAddress;
} }
/** /**
* @returns the starting address. * @returns the starting address.
*/ */
public int startAddress() { public int startAddress() {
return startAddress; return startAddress;
} }
/** /**
* @returns the ending address. * @returns the ending address.
*/ */
public int endAddress() { public int endAddress() {
return endAddress; return endAddress;
} }
/** /**
* Checks for address inclusion in the range. * Checks for address inclusion in the range.
* *
* @returns true if the address is included within this range, * @returns true if the address is included within this range,
* false otherwise. * false otherwise.
*/ */
public boolean includes(int address) { public boolean includes(int address) {
return (address <= endAddress && return (address <= endAddress &&
address >= startAddress); address >= startAddress);
} }
/** /**
* Checks for overlapping memory ranges. * Checks for overlapping memory ranges.
* *
* @returns true if this range overlaps in any way with the other. * @returns true if this range overlaps in any way with the other.
*/ */
public boolean overlaps(MemoryRange other) { public boolean overlaps(MemoryRange other) {
return (this.includes(other.startAddress()) || return (this.includes(other.startAddress()) ||
other.includes(this.startAddress())); other.includes(this.startAddress()));
} }
// Implementation of Comparable interface // Implementation of Comparable interface
public int compareTo(MemoryRange other) { public int compareTo(MemoryRange other) {
if (other == null) { if (other == null) {
throw new NullPointerException("Cannot compare to null."); throw new NullPointerException("Cannot compare to null.");
} }
if (this == other) { if (this == other) {
return 0; return 0;
} }
Integer thisStartAddr = new Integer(this.startAddress()); Integer thisStartAddr = new Integer(this.startAddress());
Integer thatStartAddr = new Integer(other.startAddress()); Integer thatStartAddr = new Integer(other.startAddress());
return thisStartAddr.compareTo(thatStartAddr); return thisStartAddr.compareTo(thatStartAddr);
} }
public String toString() { public String toString() {
StringBuffer desc = new StringBuffer("@"); StringBuffer desc = new StringBuffer("@");
desc.append(String.format("0x%04x", startAddress)); desc.append(String.format("0x%04x", startAddress));
desc.append("-"); desc.append("-");
desc.append(String.format("0x%04x", endAddress)); desc.append(String.format("0x%04x", endAddress));
return desc.toString(); return desc.toString();
} }
} }
+119 -120
View File
@@ -10,151 +10,150 @@ import com.loomcom.symon.exceptions.*;
public class Profiler implements InstructionTable { public class Profiler implements InstructionTable {
public static void main(String[] args) {
// new Profiler().profileMemoryReads();
// new Profiler().dumpOpCodes();
new Profiler().profileProgram();
}
public static void main(String[] args) { public void dumpOpCodes() {
// new Profiler().profileMemoryReads(); for (int i = 0; i < 0x100; i++) {
// new Profiler().dumpOpCodes(); String name = opcodeNames[i];
new Profiler().profileProgram(); Mode mode = instructionModes[i];
}
public void dumpOpCodes() { System.out.print(String.format("0x%02x: ", i));
for (int i = 0; i < 0x100; i++) {
String name = opcodeNames[i];
Mode mode = instructionModes[i];
System.out.print(String.format("0x%02x: ", i)); if (name == null) {
System.out.println("n/a");
} else {
System.out.println(name + " (" + mode + ")");
}
}
}
if (name == null) { public void profileProgram() {
System.out.println("n/a"); Bus bus = new Bus(0, 65535);
} else { Cpu cpu = new Cpu();
System.out.println(name + " (" + mode + ")");
}
}
}
public void profileProgram() { bus.addCpu(cpu);
Bus bus = new Bus(0, 65535);
Cpu cpu = new Cpu();
bus.addCpu(cpu); try {
bus.addDevice(new Memory(0x0000, 0x10000));
} catch (MemoryRangeException ex) {
System.err.println("Memory Range Exception! " + ex.getMessage());
return;
}
try { // Start at 0x0300
bus.addDevice(new Memory(0x0000, 0x10000)); bus.write(0xfffc, 0x00);
} catch (MemoryRangeException ex) { bus.write(0xfffd, 0x03);
System.err.println("Memory Range Exception! " + ex.getMessage());
return;
}
// Start at 0x0300 // The program to run, in an infinite loop.
bus.write(0xfffc, 0x00); bus.write(0x0300, 0xa9); // LDA #$FF
bus.write(0xfffd, 0x03); bus.write(0x0301, 0xff);
bus.write(0x0302, 0xea); // NOP
bus.write(0x0303, 0xea); // NOP
bus.write(0x0304, 0xa0); // LDY #$1A
bus.write(0x0305, 0x1a);
bus.write(0x0306, 0xea); // NOP
bus.write(0x0307, 0xea); // NOP
bus.write(0x0308, 0xa2); // LDX #$03
bus.write(0x0309, 0x03);
// The program to run, in an infinite loop. bus.write(0x030a, 0xa9); // LDA #$00
bus.write(0x0300, 0xa9); // LDA #$FF bus.write(0x030b, 0x00);
bus.write(0x0301, 0xff); bus.write(0x030c, 0xa2); // LDX #$00
bus.write(0x0302, 0xea); // NOP bus.write(0x030d, 0x00);
bus.write(0x0303, 0xea); // NOP bus.write(0x030e, 0xa0); // LDY #$00
bus.write(0x0304, 0xa0); // LDY #$1A bus.write(0x030f, 0x00);
bus.write(0x0305, 0x1a);
bus.write(0x0306, 0xea); // NOP
bus.write(0x0307, 0xea); // NOP
bus.write(0x0308, 0xa2); // LDX #$03
bus.write(0x0309, 0x03);
bus.write(0x030a, 0xa9); // LDA #$00 bus.write(0x0310, 0x4c); // JMP #$0300
bus.write(0x030b, 0x00); bus.write(0x0311, 0x00);
bus.write(0x030c, 0xa2); // LDX #$00 bus.write(0x0312, 0x03);
bus.write(0x030d, 0x00);
bus.write(0x030e, 0xa0); // LDY #$00
bus.write(0x030f, 0x00);
bus.write(0x0310, 0x4c); // JMP #$0300
bus.write(0x0311, 0x00);
bus.write(0x0312, 0x03);
long sum = 0; long sum = 0;
// The number of times to run the program // The number of times to run the program
long iters = 1000; long iters = 1000;
// The number of steps to take when running the program // The number of steps to take when running the program
long steps = 100000; long steps = 100000;
for (int i = 0; i < iters; i++) { for (int i = 0; i < iters; i++) {
long startTime = System.nanoTime(); long startTime = System.nanoTime();
// Reset the CPU (does not clear memory) // Reset the CPU (does not clear memory)
cpu.reset(); cpu.reset();
for (int j = 0; j < steps; j++) { for (int j = 0; j < steps; j++) {
cpu.step(); cpu.step();
} }
long endTime = System.nanoTime(); long endTime = System.nanoTime();
long diff = endTime - startTime; long diff = endTime - startTime;
sum += diff; sum += diff;
} }
long average = sum / iters; long average = sum / iters;
long totalSteps = steps * iters; long totalSteps = steps * iters;
long avgStep = sum / totalSteps; long avgStep = sum / totalSteps;
System.out.println("Total instructions executed: " + System.out.println("Total instructions executed: " +
String.format("%,d", totalSteps)); String.format("%,d", totalSteps));
System.out.println("Total time taken: " + System.out.println("Total time taken: " +
String.format("%,d us", sum / 1000)); String.format("%,d us", sum / 1000));
System.out.println("Average time per step: " + System.out.println("Average time per step: " +
avgStep + " ns "); avgStep + " ns ");
} }
public void profileMemoryReads() { public void profileMemoryReads() {
// Create a bus. // Create a bus.
Bus b = new Bus(0, 65535); Bus b = new Bus(0, 65535);
try { try {
// Create eight devices, each 8KB, to fill the bus. // Create eight devices, each 8KB, to fill the bus.
b.addDevice(new Memory(0x0000, 0x2000)); // 8KB @ $0000-$1fff b.addDevice(new Memory(0x0000, 0x2000)); // 8KB @ $0000-$1fff
b.addDevice(new Memory(0x2000, 0x2000)); // 8KB @ $2000-$3fff b.addDevice(new Memory(0x2000, 0x2000)); // 8KB @ $2000-$3fff
b.addDevice(new Memory(0x4000, 0x2000)); // 8KB @ $4000-$5fff b.addDevice(new Memory(0x4000, 0x2000)); // 8KB @ $4000-$5fff
b.addDevice(new Memory(0x6000, 0x2000)); // 8KB @ $6000-$7fff b.addDevice(new Memory(0x6000, 0x2000)); // 8KB @ $6000-$7fff
b.addDevice(new Memory(0x8000, 0x2000)); // 8KB @ $8000-$9fff b.addDevice(new Memory(0x8000, 0x2000)); // 8KB @ $8000-$9fff
b.addDevice(new Memory(0xa000, 0x2000)); // 8KB @ $a000-$bfff b.addDevice(new Memory(0xa000, 0x2000)); // 8KB @ $a000-$bfff
b.addDevice(new Memory(0xc000, 0x2000)); // 8KB @ $c000-$dfff b.addDevice(new Memory(0xc000, 0x2000)); // 8KB @ $c000-$dfff
b.addDevice(new Memory(0xe000, 0x2000)); // 8KB @ $e000-$ffff b.addDevice(new Memory(0xe000, 0x2000)); // 8KB @ $e000-$ffff
} catch (MemoryRangeException ex) { } catch (MemoryRangeException ex) {
System.err.println("Memory Range Exception! " + ex.getMessage()); System.err.println("Memory Range Exception! " + ex.getMessage());
return; return;
} }
// Read memory // Read memory
long sum = 0; long sum = 0;
long average = 0; long average = 0;
long iters = 500; long iters = 500;
for (int i = 0; i < iters; i++) { for (int i = 0; i < iters; i++) {
long startTime = System.nanoTime(); long startTime = System.nanoTime();
// Read and assign to a buffer // Read and assign to a buffer
int buf = 0; int buf = 0;
for (int j = 0; j < 0xffff; j++) { for (int j = 0; j < 0xffff; j++) {
buf = b.read(j); buf = b.read(j);
if (buf != 0xff) { if (buf != 0xff) {
System.out.println("WARNING! MEMORY SHOULD HAVE " + System.out.println("WARNING! MEMORY SHOULD HAVE " +
"BEEN $FF, WAS: " + buf); "BEEN $FF, WAS: " + buf);
System.exit(0); System.exit(0);
} }
} }
long endTime = System.nanoTime(); long endTime = System.nanoTime();
long diff = endTime - startTime; long diff = endTime - startTime;
sum += diff; sum += diff;
average = sum / (i + 1); average = sum / (i + 1);
} }
System.out.println("Average time to read 64KB: " + average + System.out.println("Average time to read 64KB: " + average +
" ns (" + (average / 1000) + " us)"); " ns (" + (average / 1000) + " us)");
System.out.println("Average time to read one byte: " + System.out.println("Average time to read one byte: " +
sum / (64 * 1024 * iters) + " ns"); sum / (64 * 1024 * iters) + " ns");
} }
} }
+86 -86
View File
@@ -8,107 +8,107 @@ import com.loomcom.symon.exceptions.*;
*/ */
public class Simulator { public class Simulator {
/** /**
* Command-line parser used by this simulator. * Command-line parser used by this simulator.
*/ */
private CommandParser parser; private CommandParser parser;
/** /**
* The CPU itself. * The CPU itself.
*/ */
private Cpu cpu; private Cpu cpu;
/** /**
* The Bus responsible for routing memory read/write requests to the * The Bus responsible for routing memory read/write requests to the
* correct IO devices. * correct IO devices.
*/ */
private Bus bus; private Bus bus;
public Simulator() throws MemoryRangeException { public Simulator() throws MemoryRangeException {
cpu = new Cpu(); cpu = new Cpu();
bus = new Bus(0x0000, 0xffff); bus = new Bus(0x0000, 0xffff);
bus.addCpu(cpu); bus.addCpu(cpu);
bus.addDevice(new Memory(0x0000, 0x10000)); bus.addDevice(new Memory(0x0000, 0x10000));
parser = new CommandParser(System.in, System.out, this); parser = new CommandParser(System.in, System.out, this);
} }
public void run() { public void run() {
parser.run(); parser.run();
} }
public void step() { public void step() {
} }
public int read(int address) { public int read(int address) {
return 0; return 0;
} }
public void write(int address, int value) { public void write(int address, int value) {
} }
public void loadProgram(int address, int[] program) { public void loadProgram(int address, int[] program) {
// Reset interrupt vector // Reset interrupt vector
int hi = (address&0xff00)>>>8; int hi = (address&0xff00)>>>8;
int lo = address&0x00ff; int lo = address&0x00ff;
bus.write(0xfffc, lo); bus.write(0xfffc, lo);
bus.write(0xfffd, hi); bus.write(0xfffd, hi);
int i = 0; int i = 0;
for (int d : program) { for (int d : program) {
bus.write(address + i++, d); bus.write(address + i++, d);
} }
} }
/** /**
* A test method. * A test method.
*/ */
public void runTest() { public void runTest() {
int[] program = { int[] program = {
0xa9, // LDA #$FF 0xa9, // LDA #$FF
0xff, 0xff,
0xa0, // LDY #$1A 0xa0, // LDY #$1A
0x1a, 0x1a,
0xa2, // LDX #$90 0xa2, // LDX #$90
0x90, 0x90,
0xa2, // LDX #$02 0xa2, // LDX #$02
0x02, 0x02,
0x49, // EOR #$FF 0x49, // EOR #$FF
0xff, 0xff,
0xa9, // LDA #$00 0xa9, // LDA #$00
0x00, 0x00,
0xa2, // LDX #$00 0xa2, // LDX #$00
0x00, 0x00,
0x29, // AND #$FF 0x29, // AND #$FF
0xff, 0xff,
0xa0, // LDY #$00 0xa0, // LDY #$00
0x00, 0x00,
0x4c, // JMP #$0300 0x4c, // JMP #$0300
0x00, 0x00,
0x03 0x03
}; };
loadProgram(0x0300, program); loadProgram(0x0300, program);
cpu.reset(); cpu.reset();
int steps = program.length; int steps = program.length;
for (int i = 0; i <= steps; i++) { for (int i = 0; i <= steps; i++) {
cpu.step(); cpu.step();
System.out.println(cpu.toString()); System.out.println(cpu.toString());
} }
} }
/** /**
* Main simulator routine. * Main simulator routine.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
try { try {
new Simulator().runTest(); new Simulator().runTest();
} catch (MemoryRangeException ex) { } catch (MemoryRangeException ex) {
System.err.println("Error: " + ex.toString()); System.err.println("Error: " + ex.toString());
} }
} }
} }
@@ -9,65 +9,65 @@ import com.loomcom.symon.exceptions.*;
public abstract class Device implements Comparable<Device> { public abstract class Device implements Comparable<Device> {
/** The memory range for this device. */ /** The memory range for this device. */
private MemoryRange memoryRange; private MemoryRange memoryRange;
/** The name of the device. */ /** The name of the device. */
private String name; private String name;
/** Reference to the bus where this Device is attached. */ /** Reference to the bus where this Device is attached. */
private Bus bus; private Bus bus;
public Device(int address, int size, String name) public Device(int address, int size, String name)
throws MemoryRangeException { throws MemoryRangeException {
this.memoryRange = new MemoryRange(address, address + size - 1); this.memoryRange = new MemoryRange(address, address + size - 1);
this.name = name; this.name = name;
} }
public Device(int address, int size) throws MemoryRangeException { public Device(int address, int size) throws MemoryRangeException {
this(address, size, null); this(address, size, null);
} }
/* Methods required to be implemented by inheriting classes. */ /* Methods required to be implemented by inheriting classes. */
public abstract void write(int address, int data); public abstract void write(int address, int data);
public abstract int read(int address); public abstract int read(int address);
public abstract String toString(); public abstract String toString();
public void setBus(Bus bus) { public void setBus(Bus bus) {
this.bus = bus; this.bus = bus;
} }
public MemoryRange getMemoryRange() { public MemoryRange getMemoryRange() {
return memoryRange; return memoryRange;
} }
public int endAddress() { public int endAddress() {
return memoryRange.endAddress(); return memoryRange.endAddress();
} }
public int startAddress() { public int startAddress() {
return memoryRange.startAddress(); return memoryRange.startAddress();
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Compares two devices. The sort order is defined by the sort * Compares two devices. The sort order is defined by the sort
* order of the device's memory ranges. * order of the device's memory ranges.
*/ */
public int compareTo(Device other) { public int compareTo(Device other) {
if (other == null) { if (other == null) {
throw new NullPointerException("Cannot compare to null."); throw new NullPointerException("Cannot compare to null.");
} }
if (this == other) { if (this == other) {
return 0; return 0;
} }
return getMemoryRange().compareTo(other.getMemoryRange()); return getMemoryRange().compareTo(other.getMemoryRange());
} }
} }
@@ -7,33 +7,33 @@ import com.loomcom.symon.exceptions.*;
public class Memory extends Device { public class Memory extends Device {
private boolean readOnly; private boolean readOnly;
private int[] mem; private int[] mem;
public Memory(int address, int size, boolean readOnly) public Memory(int address, int size, boolean readOnly)
throws MemoryRangeException { throws MemoryRangeException {
super(address, size, "RW Memory"); super(address, size, "RW Memory");
this.readOnly = readOnly; this.readOnly = readOnly;
this.mem = new int[size]; this.mem = new int[size];
// Initialize all locations to 0xff // Initialize all locations to 0xff
Arrays.fill(this.mem, 0xff); Arrays.fill(this.mem, 0xff);
} }
public Memory(int address, int size) public Memory(int address, int size)
throws MemoryRangeException { throws MemoryRangeException {
this(address, size, false); this(address, size, false);
} }
public void write(int address, int data) { public void write(int address, int data) {
this.mem[address] = data; this.mem[address] = data;
} }
public int read(int address) { public int read(int address) {
return this.mem[address]; return this.mem[address];
} }
public String toString() { public String toString() {
return "Memory: " + getMemoryRange().toString(); return "Memory: " + getMemoryRange().toString();
} }
} }
@@ -5,7 +5,7 @@ package com.loomcom.symon.exceptions;
* accessed. * accessed.
*/ */
public class MemoryAccessException extends Exception { public class MemoryAccessException extends Exception {
public MemoryAccessException(String msg) { public MemoryAccessException(String msg) {
super(msg); super(msg);
} }
} }
@@ -4,7 +4,7 @@ package com.loomcom.symon.exceptions;
* Exception that will be thrown if devices conflict in the IO map. * Exception that will be thrown if devices conflict in the IO map.
*/ */
public class MemoryRangeException extends Exception { public class MemoryRangeException extends Exception {
public MemoryRangeException(String msg) { public MemoryRangeException(String msg) {
super(msg); super(msg);
} }
} }
+86 -86
View File
@@ -12,114 +12,114 @@ import java.util.*;
*/ */
public class BusTest extends TestCase { public class BusTest extends TestCase {
public BusTest(String testName) { public BusTest(String testName) {
super(testName); super(testName);
} }
public static Test suite() { public static Test suite() {
return new TestSuite(BusTest.class); return new TestSuite(BusTest.class);
} }
public void testCreatingWithStartAndEndAddresses() { public void testCreatingWithStartAndEndAddresses() {
Bus b = null; Bus b = null;
b = new Bus(0x00, 0xff); b = new Bus(0x00, 0xff);
assertEquals(0x00, b.startAddress()); assertEquals(0x00, b.startAddress());
assertEquals(0xff, b.endAddress()); assertEquals(0xff, b.endAddress());
b = new Bus(0x20, 0xea); b = new Bus(0x20, 0xea);
assertEquals(0x20, b.startAddress()); assertEquals(0x20, b.startAddress());
assertEquals(0xea, b.endAddress()); assertEquals(0xea, b.endAddress());
} }
public void testCreatingWithSize() { public void testCreatingWithSize() {
Bus b = null; Bus b = null;
b = new Bus(256); b = new Bus(256);
assertEquals(0x00, b.startAddress()); assertEquals(0x00, b.startAddress());
assertEquals(0xff, b.endAddress()); assertEquals(0xff, b.endAddress());
b = new Bus(4096); b = new Bus(4096);
assertEquals(0x000, b.startAddress()); assertEquals(0x000, b.startAddress());
assertEquals(0xfff, b.endAddress()); assertEquals(0xfff, b.endAddress());
b = new Bus(65536); b = new Bus(65536);
assertEquals(0x0000, b.startAddress()); assertEquals(0x0000, b.startAddress());
assertEquals(0xffff, b.endAddress()); assertEquals(0xffff, b.endAddress());
} }
public void testAddDevice() throws MemoryRangeException { public void testAddDevice() throws MemoryRangeException {
Device memory = new Memory(0x0000, 0x0100, true); Device memory = new Memory(0x0000, 0x0100, true);
Device rom = new Memory(0x0100, 0x0200, false); Device rom = new Memory(0x0100, 0x0200, false);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
assertEquals(0, b.getDevices().size()); assertEquals(0, b.getDevices().size());
b.addDevice(memory); b.addDevice(memory);
assertEquals(1, b.getDevices().size()); assertEquals(1, b.getDevices().size());
b.addDevice(rom); b.addDevice(rom);
assertEquals(2, b.getDevices().size()); assertEquals(2, b.getDevices().size());
} }
public void testOverlappingDevicesShouldFail() throws MemoryRangeException { public void testOverlappingDevicesShouldFail() throws MemoryRangeException {
Device memory = new Memory(0x0000, 0x0100, true); Device memory = new Memory(0x0000, 0x0100, true);
Device rom = new Memory(0x00ff, 0x0200, false); Device rom = new Memory(0x00ff, 0x0200, false);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
b.addDevice(memory); b.addDevice(memory);
try { try {
b.addDevice(rom); b.addDevice(rom);
fail("Should have thrown a MemoryRangeException."); fail("Should have thrown a MemoryRangeException.");
} catch (MemoryRangeException ex) { } catch (MemoryRangeException ex) {
// expected // expected
} }
} }
public void testIsCompleteWithFirstDeviceNotStartingAtStartAddress() throws MemoryRangeException { public void testIsCompleteWithFirstDeviceNotStartingAtStartAddress() throws MemoryRangeException {
Device memory = new Memory(0x00ff, 0xff00, true); Device memory = new Memory(0x00ff, 0xff00, true);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(memory); b.addDevice(memory);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
} }
public void testIsCompleteWithOneDevice() throws MemoryRangeException { public void testIsCompleteWithOneDevice() throws MemoryRangeException {
Device memory = new Memory(0x0000, 0x10000, true); Device memory = new Memory(0x0000, 0x10000, true);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(memory); b.addDevice(memory);
assertTrue("Address space should have been complete!", b.isComplete()); assertTrue("Address space should have been complete!", b.isComplete());
} }
public void testIsCompleteWithTwoDevices() throws MemoryRangeException { public void testIsCompleteWithTwoDevices() throws MemoryRangeException {
Device memory = new Memory(0x0000, 0x8000, true); Device memory = new Memory(0x0000, 0x8000, true);
Device rom = new Memory(0x8000, 0x8000, false); Device rom = new Memory(0x8000, 0x8000, false);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(memory); b.addDevice(memory);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(rom); b.addDevice(rom);
assertTrue("Address space should have been complete!", b.isComplete()); assertTrue("Address space should have been complete!", b.isComplete());
} }
public void testIsCompleteWithThreeDevices() throws MemoryRangeException { public void testIsCompleteWithThreeDevices() throws MemoryRangeException {
Device memory = new Memory(0x0000, 0x8000, true); Device memory = new Memory(0x0000, 0x8000, true);
Device rom1 = new Memory(0x8000, 0x4000, false); Device rom1 = new Memory(0x8000, 0x4000, false);
Device rom2 = new Memory(0xC000, 0x4000, false); Device rom2 = new Memory(0xC000, 0x4000, false);
Bus b = new Bus(0x0000, 0xffff); Bus b = new Bus(0x0000, 0xffff);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(memory); b.addDevice(memory);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(rom1); b.addDevice(rom1);
assertFalse("Address space was unexpectedly complete!", b.isComplete()); assertFalse("Address space was unexpectedly complete!", b.isComplete());
b.addDevice(rom2); b.addDevice(rom2);
assertTrue("Address space should have been complete!", b.isComplete()); assertTrue("Address space should have been complete!", b.isComplete());
} }
} }
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+344 -344
View File
@@ -10,349 +10,349 @@ import com.loomcom.symon.exceptions.*;
*/ */
public class CpuTest extends TestCase { public class CpuTest extends TestCase {
private Cpu cpu; private Cpu cpu;
private Bus bus; private Bus bus;
private Memory mem; private Memory mem;
public CpuTest(String testName) { public CpuTest(String testName) {
super(testName); super(testName);
} }
public static Test suite() { public static Test suite() {
return new TestSuite(CpuTest.class); return new TestSuite(CpuTest.class);
} }
public void setUp() throws MemoryRangeException { public void setUp() throws MemoryRangeException {
this.cpu = new Cpu(); this.cpu = new Cpu();
this.bus = new Bus(0x0000, 0xffff); this.bus = new Bus(0x0000, 0xffff);
this.mem = new Memory(0x0000, 0x10000); this.mem = new Memory(0x0000, 0x10000);
bus.addCpu(cpu); bus.addCpu(cpu);
bus.addDevice(mem); bus.addDevice(mem);
// All test programs start at 0x0200; // All test programs start at 0x0200;
bus.write(0xfffc, 0x00); bus.write(0xfffc, 0x00);
bus.write(0xfffd, 0x02); bus.write(0xfffd, 0x02);
cpu.reset(); cpu.reset();
} }
public void testReset() { public void testReset() {
assertEquals(0, cpu.getAccumulator()); assertEquals(0, cpu.getAccumulator());
assertEquals(0, cpu.getXRegister()); assertEquals(0, cpu.getXRegister());
assertEquals(0, cpu.getYRegister()); assertEquals(0, cpu.getYRegister());
assertEquals(0x0200, cpu.getProgramCounter()); assertEquals(0x0200, cpu.getProgramCounter());
assertFalse(cpu.getCarryFlag()); assertFalse(cpu.getCarryFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertFalse(cpu.getNegativeFlag()); assertFalse(cpu.getNegativeFlag());
} }
public void testStack() { public void testStack() {
cpu.stackPush(0x13); cpu.stackPush(0x13);
assertEquals(0x13, cpu.stackPop()); assertEquals(0x13, cpu.stackPop());
cpu.stackPush(0x12); cpu.stackPush(0x12);
assertEquals(0x12, cpu.stackPop()); assertEquals(0x12, cpu.stackPop());
for (int i = 0x00; i <= 0xff; i++) { for (int i = 0x00; i <= 0xff; i++) {
cpu.stackPush(i); cpu.stackPush(i);
} }
for (int i = 0xff; i >= 0x00; i--) { for (int i = 0xff; i >= 0x00; i--) {
assertEquals(i, cpu.stackPop()); assertEquals(i, cpu.stackPop());
} }
} }
public void testStackPush() { public void testStackPush() {
assertEquals(0xff, cpu.getStackPointer()); assertEquals(0xff, cpu.getStackPointer());
assertEquals(0xff, bus.read(0x1ff)); assertEquals(0xff, bus.read(0x1ff));
cpu.stackPush(0x06); cpu.stackPush(0x06);
assertEquals(0xfe, cpu.getStackPointer()); assertEquals(0xfe, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
cpu.stackPush(0x05); cpu.stackPush(0x05);
assertEquals(0xfd, cpu.getStackPointer()); assertEquals(0xfd, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
assertEquals(0x05, bus.read(0x1fe)); assertEquals(0x05, bus.read(0x1fe));
cpu.stackPush(0x04); cpu.stackPush(0x04);
assertEquals(0xfc, cpu.getStackPointer()); assertEquals(0xfc, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
assertEquals(0x05, bus.read(0x1fe)); assertEquals(0x05, bus.read(0x1fe));
assertEquals(0x04, bus.read(0x1fd)); assertEquals(0x04, bus.read(0x1fd));
cpu.stackPush(0x03); cpu.stackPush(0x03);
assertEquals(0xfb, cpu.getStackPointer()); assertEquals(0xfb, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
assertEquals(0x05, bus.read(0x1fe)); assertEquals(0x05, bus.read(0x1fe));
assertEquals(0x04, bus.read(0x1fd)); assertEquals(0x04, bus.read(0x1fd));
assertEquals(0x03, bus.read(0x1fc)); assertEquals(0x03, bus.read(0x1fc));
cpu.stackPush(0x02); cpu.stackPush(0x02);
assertEquals(0xfa, cpu.getStackPointer()); assertEquals(0xfa, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
assertEquals(0x05, bus.read(0x1fe)); assertEquals(0x05, bus.read(0x1fe));
assertEquals(0x04, bus.read(0x1fd)); assertEquals(0x04, bus.read(0x1fd));
assertEquals(0x03, bus.read(0x1fc)); assertEquals(0x03, bus.read(0x1fc));
assertEquals(0x02, bus.read(0x1fb)); assertEquals(0x02, bus.read(0x1fb));
cpu.stackPush(0x01); cpu.stackPush(0x01);
assertEquals(0xf9, cpu.getStackPointer()); assertEquals(0xf9, cpu.getStackPointer());
assertEquals(0x06, bus.read(0x1ff)); assertEquals(0x06, bus.read(0x1ff));
assertEquals(0x05, bus.read(0x1fe)); assertEquals(0x05, bus.read(0x1fe));
assertEquals(0x04, bus.read(0x1fd)); assertEquals(0x04, bus.read(0x1fd));
assertEquals(0x03, bus.read(0x1fc)); assertEquals(0x03, bus.read(0x1fc));
assertEquals(0x02, bus.read(0x1fb)); assertEquals(0x02, bus.read(0x1fb));
assertEquals(0x01, bus.read(0x1fa)); assertEquals(0x01, bus.read(0x1fa));
} }
public void testStackPushWrapsAroundToStackTop() { public void testStackPushWrapsAroundToStackTop() {
cpu.setStackPointer(0x01); cpu.setStackPointer(0x01);
cpu.stackPush(0x01); cpu.stackPush(0x01);
assertEquals(0x01, bus.read(0x101)); assertEquals(0x01, bus.read(0x101));
assertEquals(0x00, cpu.getStackPointer()); assertEquals(0x00, cpu.getStackPointer());
cpu.stackPush(0x02); cpu.stackPush(0x02);
assertEquals(0x02, bus.read(0x100)); assertEquals(0x02, bus.read(0x100));
assertEquals(0xff, cpu.getStackPointer()); assertEquals(0xff, cpu.getStackPointer());
cpu.stackPush(0x03); cpu.stackPush(0x03);
assertEquals(0x03, bus.read(0x1ff)); assertEquals(0x03, bus.read(0x1ff));
assertEquals(0xfe, cpu.getStackPointer()); assertEquals(0xfe, cpu.getStackPointer());
} }
public void testStackPop() { public void testStackPop() {
bus.write(0x1ff, 0x06); bus.write(0x1ff, 0x06);
bus.write(0x1fe, 0x05); bus.write(0x1fe, 0x05);
bus.write(0x1fd, 0x04); bus.write(0x1fd, 0x04);
bus.write(0x1fc, 0x03); bus.write(0x1fc, 0x03);
bus.write(0x1fb, 0x02); bus.write(0x1fb, 0x02);
bus.write(0x1fa, 0x01); bus.write(0x1fa, 0x01);
cpu.setStackPointer(0xf9); cpu.setStackPointer(0xf9);
assertEquals(0x01, cpu.stackPop()); assertEquals(0x01, cpu.stackPop());
assertEquals(0xfa, cpu.getStackPointer()); assertEquals(0xfa, cpu.getStackPointer());
assertEquals(0x02, cpu.stackPop()); assertEquals(0x02, cpu.stackPop());
assertEquals(0xfb, cpu.getStackPointer()); assertEquals(0xfb, cpu.getStackPointer());
assertEquals(0x03, cpu.stackPop()); assertEquals(0x03, cpu.stackPop());
assertEquals(0xfc, cpu.getStackPointer()); assertEquals(0xfc, cpu.getStackPointer());
assertEquals(0x04, cpu.stackPop()); assertEquals(0x04, cpu.stackPop());
assertEquals(0xfd, cpu.getStackPointer()); assertEquals(0xfd, cpu.getStackPointer());
assertEquals(0x05, cpu.stackPop()); assertEquals(0x05, cpu.stackPop());
assertEquals(0xfe, cpu.getStackPointer()); assertEquals(0xfe, cpu.getStackPointer());
assertEquals(0x06, cpu.stackPop()); assertEquals(0x06, cpu.stackPop());
assertEquals(0xff, cpu.getStackPointer()); assertEquals(0xff, cpu.getStackPointer());
} }
public void testStackPopWrapsAroundToStackBottom() { public void testStackPopWrapsAroundToStackBottom() {
bus.write(0x1ff, 0x0f); // top of stack bus.write(0x1ff, 0x0f); // top of stack
bus.write(0x100, 0xf0); // bottom of stack bus.write(0x100, 0xf0); // bottom of stack
bus.write(0x101, 0xf1); bus.write(0x101, 0xf1);
bus.write(0x102, 0xf2); bus.write(0x102, 0xf2);
cpu.setStackPointer(0xfe); cpu.setStackPointer(0xfe);
assertEquals(0x0f, cpu.stackPop()); assertEquals(0x0f, cpu.stackPop());
assertEquals(0xff, cpu.getStackPointer()); assertEquals(0xff, cpu.getStackPointer());
assertEquals(0xf0, cpu.stackPop()); assertEquals(0xf0, cpu.stackPop());
assertEquals(0x00, cpu.getStackPointer()); assertEquals(0x00, cpu.getStackPointer());
assertEquals(0xf1, cpu.stackPop()); assertEquals(0xf1, cpu.stackPop());
assertEquals(0x01, cpu.getStackPointer()); assertEquals(0x01, cpu.getStackPointer());
assertEquals(0xf2, cpu.stackPop()); assertEquals(0xf2, cpu.stackPop());
assertEquals(0x02, cpu.getStackPointer()); assertEquals(0x02, cpu.getStackPointer());
} }
public void testStackPeekDoesNotAlterStackPointer() { public void testStackPeekDoesNotAlterStackPointer() {
int val = 0; int val = 0;
assertEquals(0xff, cpu.stackPeek()); assertEquals(0xff, cpu.stackPeek());
assertEquals(0xff, cpu.getStackPointer()); assertEquals(0xff, cpu.getStackPointer());
cpu.stackPush(0x01); cpu.stackPush(0x01);
assertEquals(0x01, cpu.stackPeek()); assertEquals(0x01, cpu.stackPeek());
assertEquals(0xfe, cpu.getStackPointer()); assertEquals(0xfe, cpu.getStackPointer());
cpu.stackPush(0x02); cpu.stackPush(0x02);
assertEquals(0x02, cpu.stackPeek()); assertEquals(0x02, cpu.stackPeek());
assertEquals(0xfd, cpu.getStackPointer()); assertEquals(0xfd, cpu.getStackPointer());
cpu.stackPush(0x03); cpu.stackPush(0x03);
assertEquals(0x03, cpu.stackPeek()); assertEquals(0x03, cpu.stackPeek());
assertEquals(0xfc, cpu.getStackPointer()); assertEquals(0xfc, cpu.getStackPointer());
cpu.stackPush(0x04); cpu.stackPush(0x04);
assertEquals(0x04, cpu.stackPeek()); assertEquals(0x04, cpu.stackPeek());
assertEquals(0xfb, cpu.getStackPointer()); assertEquals(0xfb, cpu.getStackPointer());
assertEquals(0x04, cpu.stackPeek()); assertEquals(0x04, cpu.stackPeek());
assertEquals(0xfb, cpu.getStackPointer()); assertEquals(0xfb, cpu.getStackPointer());
assertEquals(0x04, cpu.stackPeek()); assertEquals(0x04, cpu.stackPeek());
assertEquals(0xfb, cpu.getStackPointer()); assertEquals(0xfb, cpu.getStackPointer());
} }
public void testGetProcessorStatus() { public void testGetProcessorStatus() {
// By default, no flags are set. Remember, bit 5 // By default, no flags are set. Remember, bit 5
// is always '1'. // is always '1'.
assertEquals(0x20, cpu.getProcessorStatus()); assertEquals(0x20, cpu.getProcessorStatus());
cpu.setCarryFlag(); cpu.setCarryFlag();
assertEquals(0x21, cpu.getProcessorStatus()); assertEquals(0x21, cpu.getProcessorStatus());
cpu.setZeroFlag(); cpu.setZeroFlag();
assertEquals(0x23, cpu.getProcessorStatus()); assertEquals(0x23, cpu.getProcessorStatus());
cpu.setIrqDisableFlag(); cpu.setIrqDisableFlag();
assertEquals(0x27, cpu.getProcessorStatus()); assertEquals(0x27, cpu.getProcessorStatus());
cpu.setDecimalModeFlag(); cpu.setDecimalModeFlag();
assertEquals(0x2f, cpu.getProcessorStatus()); assertEquals(0x2f, cpu.getProcessorStatus());
cpu.setBreakFlag(); cpu.setBreakFlag();
assertEquals(0x3f, cpu.getProcessorStatus()); assertEquals(0x3f, cpu.getProcessorStatus());
cpu.setOverflowFlag(); cpu.setOverflowFlag();
assertEquals(0x7f, cpu.getProcessorStatus()); assertEquals(0x7f, cpu.getProcessorStatus());
cpu.setNegativeFlag(); cpu.setNegativeFlag();
assertEquals(0xff, cpu.getProcessorStatus()); assertEquals(0xff, cpu.getProcessorStatus());
cpu.clearCarryFlag(); cpu.clearCarryFlag();
assertEquals(0xfe, cpu.getProcessorStatus()); assertEquals(0xfe, cpu.getProcessorStatus());
cpu.clearZeroFlag(); cpu.clearZeroFlag();
assertEquals(0xfc, cpu.getProcessorStatus()); assertEquals(0xfc, cpu.getProcessorStatus());
cpu.clearIrqDisableFlag(); cpu.clearIrqDisableFlag();
assertEquals(0xf8, cpu.getProcessorStatus()); assertEquals(0xf8, cpu.getProcessorStatus());
cpu.clearDecimalModeFlag(); cpu.clearDecimalModeFlag();
assertEquals(0xf0, cpu.getProcessorStatus()); assertEquals(0xf0, cpu.getProcessorStatus());
cpu.clearBreakFlag(); cpu.clearBreakFlag();
assertEquals(0xe0, cpu.getProcessorStatus()); assertEquals(0xe0, cpu.getProcessorStatus());
cpu.clearOverflowFlag(); cpu.clearOverflowFlag();
assertEquals(0xa0, cpu.getProcessorStatus()); assertEquals(0xa0, cpu.getProcessorStatus());
cpu.clearNegativeFlag(); cpu.clearNegativeFlag();
assertEquals(0x20, cpu.getProcessorStatus()); assertEquals(0x20, cpu.getProcessorStatus());
} }
public void testSetProcessorStatus() { public void testSetProcessorStatus() {
// Default // Default
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertFalse(cpu.getNegativeFlag()); assertFalse(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY); cpu.setProcessorStatus(0x20|Cpu.P_CARRY);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertFalse(cpu.getNegativeFlag()); assertFalse(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE); cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO); cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertTrue(cpu.getZeroFlag()); assertTrue(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO| cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO|
Cpu.P_OVERFLOW); Cpu.P_OVERFLOW);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertTrue(cpu.getZeroFlag()); assertTrue(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertTrue(cpu.getOverflowFlag()); assertTrue(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO| cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO|
Cpu.P_OVERFLOW|Cpu.P_BREAK); Cpu.P_OVERFLOW|Cpu.P_BREAK);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertTrue(cpu.getZeroFlag()); assertTrue(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertTrue(cpu.getBreakFlag()); assertTrue(cpu.getBreakFlag());
assertTrue(cpu.getOverflowFlag()); assertTrue(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO| cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO|
Cpu.P_OVERFLOW|Cpu.P_BREAK|Cpu.P_DECIMAL); Cpu.P_OVERFLOW|Cpu.P_BREAK|Cpu.P_DECIMAL);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertTrue(cpu.getZeroFlag()); assertTrue(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertTrue(cpu.getDecimalModeFlag()); assertTrue(cpu.getDecimalModeFlag());
assertTrue(cpu.getBreakFlag()); assertTrue(cpu.getBreakFlag());
assertTrue(cpu.getOverflowFlag()); assertTrue(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO| cpu.setProcessorStatus(0x20|Cpu.P_CARRY|Cpu.P_NEGATIVE|Cpu.P_ZERO|
Cpu.P_OVERFLOW|Cpu.P_BREAK|Cpu.P_DECIMAL| Cpu.P_OVERFLOW|Cpu.P_BREAK|Cpu.P_DECIMAL|
Cpu.P_IRQ_DISABLE); Cpu.P_IRQ_DISABLE);
assertTrue(cpu.getCarryFlag()); assertTrue(cpu.getCarryFlag());
assertTrue(cpu.getZeroFlag()); assertTrue(cpu.getZeroFlag());
assertTrue(cpu.getIrqDisableFlag()); assertTrue(cpu.getIrqDisableFlag());
assertTrue(cpu.getDecimalModeFlag()); assertTrue(cpu.getDecimalModeFlag());
assertTrue(cpu.getBreakFlag()); assertTrue(cpu.getBreakFlag());
assertTrue(cpu.getOverflowFlag()); assertTrue(cpu.getOverflowFlag());
assertTrue(cpu.getNegativeFlag()); assertTrue(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x20); cpu.setProcessorStatus(0x20);
assertFalse(cpu.getCarryFlag()); assertFalse(cpu.getCarryFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertFalse(cpu.getNegativeFlag()); assertFalse(cpu.getNegativeFlag());
cpu.setProcessorStatus(0x00); cpu.setProcessorStatus(0x00);
assertFalse(cpu.getCarryFlag()); assertFalse(cpu.getCarryFlag());
assertFalse(cpu.getZeroFlag()); assertFalse(cpu.getZeroFlag());
assertFalse(cpu.getIrqDisableFlag()); assertFalse(cpu.getIrqDisableFlag());
assertFalse(cpu.getDecimalModeFlag()); assertFalse(cpu.getDecimalModeFlag());
assertFalse(cpu.getBreakFlag()); assertFalse(cpu.getBreakFlag());
assertFalse(cpu.getOverflowFlag()); assertFalse(cpu.getOverflowFlag());
assertFalse(cpu.getNegativeFlag()); assertFalse(cpu.getNegativeFlag());
} }
public void testAddress() { public void testAddress() {
assertEquals(0xf1ea, cpu.address(0xea, 0xf1)); assertEquals(0xf1ea, cpu.address(0xea, 0xf1));
assertEquals(0x00ea, cpu.address(0xea, 0x00)); assertEquals(0x00ea, cpu.address(0xea, 0x00));
assertEquals(0xf100, cpu.address(0x00, 0xf1)); assertEquals(0xf100, cpu.address(0x00, 0xf1));
assertEquals(0x1234, cpu.address(0x34, 0x12)); assertEquals(0x1234, cpu.address(0x34, 0x12));
assertEquals(0xffff, cpu.address(0xff, 0xff)); assertEquals(0xffff, cpu.address(0xff, 0xff));
} }
} }
File diff suppressed because it is too large. Load diff
@@ -12,129 +12,129 @@ import com.loomcom.symon.exceptions.*;
*/ */
public class MemoryRangeTest extends TestCase { public class MemoryRangeTest extends TestCase {
public MemoryRangeTest(String testName) { public MemoryRangeTest(String testName) {
super(testName); super(testName);
} }
public static Test suite() { public static Test suite() {
return new TestSuite(MemoryRangeTest.class); return new TestSuite(MemoryRangeTest.class);
} }
public void testConstructorThrowsWhenInvalid() { public void testConstructorThrowsWhenInvalid() {
// All of these should raise MemoryRangeException // All of these should raise MemoryRangeException
doInvalidMemoryRangeTest(0, -1); doInvalidMemoryRangeTest(0, -1);
doInvalidMemoryRangeTest(-1, 0); doInvalidMemoryRangeTest(-1, 0);
doInvalidMemoryRangeTest(0, 0); doInvalidMemoryRangeTest(0, 0);
doInvalidMemoryRangeTest(1, 1); doInvalidMemoryRangeTest(1, 1);
doInvalidMemoryRangeTest(1, 0); doInvalidMemoryRangeTest(1, 0);
doInvalidMemoryRangeTest(2, 1); doInvalidMemoryRangeTest(2, 1);
} }
public void testConstructorShouldNotThrow() throws MemoryRangeException { public void testConstructorShouldNotThrow() throws MemoryRangeException {
// None of these should throw. // None of these should throw.
new MemoryRange(0, 1); new MemoryRange(0, 1);
new MemoryRange(0, 2); new MemoryRange(0, 2);
new MemoryRange(1, 2); new MemoryRange(1, 2);
new MemoryRange(2, 10); new MemoryRange(2, 10);
} }
public void testStartAddress() throws MemoryRangeException { public void testStartAddress() throws MemoryRangeException {
MemoryRange r = new MemoryRange(0x101, 0x202); MemoryRange r = new MemoryRange(0x101, 0x202);
assertEquals(0x101, r.startAddress()); assertEquals(0x101, r.startAddress());
} }
public void testEndAddress() throws MemoryRangeException { public void testEndAddress() throws MemoryRangeException {
MemoryRange r = new MemoryRange(0x101, 0x202); MemoryRange r = new MemoryRange(0x101, 0x202);
assertEquals(0x202, r.endAddress()); assertEquals(0x202, r.endAddress());
} }
public void testOverlaps() throws MemoryRangeException { public void testOverlaps() throws MemoryRangeException {
MemoryRange a = new MemoryRange(0x0100, 0x01ff); MemoryRange a = new MemoryRange(0x0100, 0x01ff);
MemoryRange b = new MemoryRange(0x0200, 0x02ff); MemoryRange b = new MemoryRange(0x0200, 0x02ff);
MemoryRange c = new MemoryRange(0x01a0, 0x01af); // inside a MemoryRange c = new MemoryRange(0x01a0, 0x01af); // inside a
MemoryRange d = new MemoryRange(0x00ff, 0x01a0); // overlaps a MemoryRange d = new MemoryRange(0x00ff, 0x01a0); // overlaps a
MemoryRange e = new MemoryRange(0x01a0, 0x02ff); // overlaps a MemoryRange e = new MemoryRange(0x01a0, 0x02ff); // overlaps a
MemoryRange f = new MemoryRange(0x02a0, 0x02af); // inside b MemoryRange f = new MemoryRange(0x02a0, 0x02af); // inside b
MemoryRange g = new MemoryRange(0x01ff, 0x02a0); // overlaps b MemoryRange g = new MemoryRange(0x01ff, 0x02a0); // overlaps b
MemoryRange h = new MemoryRange(0x02a0, 0x03ff); // overlaps b MemoryRange h = new MemoryRange(0x02a0, 0x03ff); // overlaps b
assertFalse(a.overlaps(b)); assertFalse(a.overlaps(b));
assertFalse(b.overlaps(a)); assertFalse(b.overlaps(a));
assertTrue(a.overlaps(c)); assertTrue(a.overlaps(c));
assertTrue(c.overlaps(a)); assertTrue(c.overlaps(a));
assertTrue(a.overlaps(d)); assertTrue(a.overlaps(d));
assertTrue(d.overlaps(a)); assertTrue(d.overlaps(a));
assertTrue(a.overlaps(e)); assertTrue(a.overlaps(e));
assertTrue(e.overlaps(a)); assertTrue(e.overlaps(a));
assertTrue(b.overlaps(f)); assertTrue(b.overlaps(f));
assertTrue(f.overlaps(b)); assertTrue(f.overlaps(b));
assertTrue(b.overlaps(g)); assertTrue(b.overlaps(g));
assertTrue(g.overlaps(b)); assertTrue(g.overlaps(b));
assertTrue(b.overlaps(h)); assertTrue(b.overlaps(h));
assertTrue(h.overlaps(b)); assertTrue(h.overlaps(b));
} }
public void testToString() throws MemoryRangeException { public void testToString() throws MemoryRangeException {
MemoryRange a = new MemoryRange(0x0abf, 0xff00); MemoryRange a = new MemoryRange(0x0abf, 0xff00);
assertEquals("@0x0abf-0xff00", a.toString()); assertEquals("@0x0abf-0xff00", a.toString());
MemoryRange b = new MemoryRange(0, 255); MemoryRange b = new MemoryRange(0, 255);
assertEquals("@0x0000-0x00ff", b.toString()); assertEquals("@0x0000-0x00ff", b.toString());
MemoryRange c = new MemoryRange(0, 65535); MemoryRange c = new MemoryRange(0, 65535);
assertEquals("@0x0000-0xffff", c.toString()); assertEquals("@0x0000-0xffff", c.toString());
} }
public void testIncluded() throws MemoryRangeException { public void testIncluded() throws MemoryRangeException {
MemoryRange a = new MemoryRange(0x0100, 0x0fff); MemoryRange a = new MemoryRange(0x0100, 0x0fff);
assertFalse(a.includes(0x0000)); assertFalse(a.includes(0x0000));
assertFalse(a.includes(0x00ff)); assertFalse(a.includes(0x00ff));
assertTrue(a.includes(0x0100)); assertTrue(a.includes(0x0100));
assertTrue(a.includes(0x0fff)); assertTrue(a.includes(0x0fff));
assertFalse(a.includes(0x1000)); assertFalse(a.includes(0x1000));
assertFalse(a.includes(0xffff)); assertFalse(a.includes(0xffff));
} }
public void testCompareTo() throws MemoryRangeException { public void testCompareTo() throws MemoryRangeException {
MemoryRange a = new MemoryRange(0x0000, 0x0100); MemoryRange a = new MemoryRange(0x0000, 0x0100);
MemoryRange b = new MemoryRange(0x0200, 0x0300); MemoryRange b = new MemoryRange(0x0200, 0x0300);
MemoryRange c = new MemoryRange(0x0200, 0x0300); MemoryRange c = new MemoryRange(0x0200, 0x0300);
// a < b // a < b
assertTrue(a.compareTo(b) == -1); assertTrue(a.compareTo(b) == -1);
// b > a // b > a
assertTrue(b.compareTo(a) == 1); assertTrue(b.compareTo(a) == 1);
// Identity // Identity
assertTrue(a.compareTo(a) == 0); assertTrue(a.compareTo(a) == 0);
assertTrue(b.compareTo(b) == 0); assertTrue(b.compareTo(b) == 0);
// Equality // Equality
assertTrue(b.compareTo(c) == 0); assertTrue(b.compareTo(c) == 0);
assertTrue(c.compareTo(b) == 0); assertTrue(c.compareTo(b) == 0);
// Null // Null
try { try {
a.compareTo(null); a.compareTo(null);
fail("Should have thrown NullPointerException"); fail("Should have thrown NullPointerException");
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
// expected // expected
} }
} }
// Helper method. // Helper method.
public void doInvalidMemoryRangeTest(int start, int end) { public void doInvalidMemoryRangeTest(int start, int end) {
try { try {
new MemoryRange(start, end); new MemoryRange(start, end);
fail("MemoryRangeException should have been thrown."); fail("MemoryRangeException should have been thrown.");
} catch (MemoryRangeException e) { } catch (MemoryRangeException e) {
// Expected. // Expected.
} }
} }
} }
@@ -8,26 +8,26 @@ import junit.framework.TestSuite;
* Unit test for the j6502 Simulator class. * Unit test for the j6502 Simulator class.
*/ */
public class SimulatorTest extends TestCase { public class SimulatorTest extends TestCase {
/** /**
* Create the test case * Create the test case
* *
* @param testName name of the test case * @param testName name of the test case
*/ */
public SimulatorTest(String testName) { public SimulatorTest(String testName) {
super(testName); super(testName);
} }
/** /**
* @return the suite of tests being tested * @return the suite of tests being tested
*/ */
public static Test suite() { public static Test suite() {
return new TestSuite(SimulatorTest.class); return new TestSuite(SimulatorTest.class);
} }
/** /**
* Rigourous Test :-) * Rigourous Test :-)
*/ */
public void testSimulator() { public void testSimulator() {
assertTrue(true); assertTrue(true);
} }
} }