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)]
|
#[derive(Debug)]
|
||||||
pub enum CPUError {
|
pub enum CPUError {
|
||||||
UnimplementedInstruction,
|
UnimplementedInstruction(decoder::Instruction),
|
||||||
OutOfBoundsException,
|
OutOfBoundsException,
|
||||||
UnsupportedAddress,
|
UnsupportedAddress,
|
||||||
DecodingError(decoder::DecodingError),
|
DecodingError(decoder::DecodingError),
|
||||||
@ -784,6 +784,13 @@ impl CPU {
|
|||||||
let r = self.get_register(r);
|
let r = self.get_register(r);
|
||||||
self.set_clear_flag(StatusFlag::BitCopyStorage, r & (1 << *v) != 0);
|
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) => {
|
Instruction::SWAP(ref r) => {
|
||||||
let rv = self.get_register(r);
|
let rv = self.get_register(r);
|
||||||
self.set_register(r, rv >> 4 | ((rv << 4) & 0xF0));
|
self.set_register(r, rv >> 4 | ((rv << 4) & 0xF0));
|
||||||
@ -792,7 +799,7 @@ impl CPU {
|
|||||||
return Err(CPUError::Breakpoint);
|
return Err(CPUError::Breakpoint);
|
||||||
}
|
}
|
||||||
Instruction::NOP => {}
|
Instruction::NOP => {}
|
||||||
_ => return Err(CPUError::UnimplementedInstruction),
|
_ => return Err(CPUError::UnimplementedInstruction(ins)),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ins.cycles())
|
Ok(ins.cycles())
|
||||||
|
|||||||
@ -37,9 +37,14 @@ fn main() {
|
|||||||
|
|
||||||
let mut chip = chip::Chip::new(log.clone(), rom);
|
let mut chip = chip::Chip::new(log.clone(), rom);
|
||||||
|
|
||||||
|
if std::env::args().nth(2).unwrap_or("0".to_string()) == "gdb" {
|
||||||
// Use GDBStub
|
// Use GDBStub
|
||||||
info!(log, "Enabling GDB backend");
|
info!(log, "Enabling GDB backend");
|
||||||
gdbstub::run(log.clone(), &mut chip);
|
gdbstub::run(log.clone(), &mut chip);
|
||||||
|
} else {
|
||||||
|
info!(log, "Running without GDB");
|
||||||
|
while chip.step() {}
|
||||||
|
}
|
||||||
warn!(log, "{}", &chip.cpu);
|
warn!(log, "{}", &chip.cpu);
|
||||||
write_file("ram.dmp", &chip.ram).unwrap();
|
write_file("ram.dmp", &chip.ram).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user