make gdb optional
This commit is contained in:
parent
19f6e29518
commit
243675342a
11
src/cpu.rs
11
src/cpu.rs
@ -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())
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@ -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();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user