make gdb optional

This commit is contained in:
Kevin Hamacher 2018-02-17 17:54:55 +01:00
parent 19f6e29518
commit 243675342a
2 changed files with 17 additions and 5 deletions

View File

@ -12,7 +12,7 @@ use slog;
#[derive(Debug)]
pub enum CPUError {
UnimplementedInstruction,
UnimplementedInstruction(decoder::Instruction),
OutOfBoundsException,
UnsupportedAddress,
DecodingError(decoder::DecodingError),
@ -784,6 +784,13 @@ impl CPU {
let r = self.get_register(r);
self.set_clear_flag(StatusFlag::BitCopyStorage, r & (1 << *v) != 0);
}
Instruction::BLD(ref r, ref v) => {
let mut rv = self.get_register(r);
if self.test_flag(StatusFlag::BitCopyStorage) {
rv |= 1 << *v;
}
let r = self.set_register(r, rv);
}
Instruction::SWAP(ref r) => {
let rv = self.get_register(r);
self.set_register(r, rv >> 4 | ((rv << 4) & 0xF0));
@ -792,7 +799,7 @@ impl CPU {
return Err(CPUError::Breakpoint);
}
Instruction::NOP => {}
_ => return Err(CPUError::UnimplementedInstruction),
_ => return Err(CPUError::UnimplementedInstruction(ins)),
}
Ok(ins.cycles())

View File

@ -37,9 +37,14 @@ fn main() {
let mut chip = chip::Chip::new(log.clone(), rom);
// Use GDBStub
info!(log, "Enabling GDB backend");
gdbstub::run(log.clone(), &mut chip);
if std::env::args().nth(2).unwrap_or("0".to_string()) == "gdb" {
// Use GDBStub
info!(log, "Enabling GDB backend");
gdbstub::run(log.clone(), &mut chip);
} else {
info!(log, "Running without GDB");
while chip.step() {}
}
warn!(log, "{}", &chip.cpu);
write_file("ram.dmp", &chip.ram).unwrap();
}