diff --git a/src/cpus/m68k/execute.rs b/src/cpus/m68k/execute.rs index 9dd27c1..3f528e1 100644 --- a/src/cpus/m68k/execute.rs +++ b/src/cpus/m68k/execute.rs @@ -130,7 +130,7 @@ impl M68k { } pub fn exception(&mut self, system: &System, number: u8, is_interrupt: bool) -> Result<(), Error> { - info!("{}: raising exception {}", DEV_NAME, number); + debug!("{}: raising exception {}", DEV_NAME, number); let offset = (number as u16) << 2; if self.cputype >= M68kType::MC68010 { self.push_word(system, offset)?; @@ -231,28 +231,28 @@ impl M68k { self.state.pc = (self.decoder.start + 2).wrapping_add(offset as u32); }, Instruction::BCHG(bitnum, target, size) => { - let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size); + let bitnum = self.get_target_value(system, bitnum, Size::Byte)?; let mut value = self.get_target_value(system, target, size)?; let mask = self.set_bit_test_flags(value, bitnum, size); value = (value & !mask) | (!(value & mask) & mask); self.set_target_value(system, target, value, size)?; }, Instruction::BCLR(bitnum, target, size) => { - let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size); + let bitnum = self.get_target_value(system, bitnum, Size::Byte)?; let mut value = self.get_target_value(system, target, size)?; let mask = self.set_bit_test_flags(value, bitnum, size); value = value & !mask; self.set_target_value(system, target, value, size)?; }, Instruction::BSET(bitnum, target, size) => { - let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size); + let bitnum = self.get_target_value(system, bitnum, Size::Byte)?; let mut value = self.get_target_value(system, target, size)?; let mask = self.set_bit_test_flags(value, bitnum, size); value = value | mask; self.set_target_value(system, target, value, size)?; }, Instruction::BTST(bitnum, target, size) => { - let bitnum = self.get_target_value(system, bitnum, Size::Byte)? % get_bit_op_max(size); + let bitnum = self.get_target_value(system, bitnum, Size::Byte)?; let value = self.get_target_value(system, target, size)?; self.set_bit_test_flags(value, bitnum, size); }, @@ -415,7 +415,7 @@ impl M68k { self.set_target_value(system, target2, value1, Size::Long)?; }, Instruction::EXT(reg, from_size, to_size) => { - let input = self.state.d_reg[reg as usize]; + let input = get_value_sized(self.state.d_reg[reg as usize], from_size); let result = match (from_size, to_size) { (Size::Byte, Size::Word) => ((((input as u8) as i8) as i16) as u16) as u32, (Size::Word, Size::Long) => (((input as u16) as i16) as i32) as u32, @@ -503,7 +503,7 @@ impl M68k { Instruction::MOVEM(target, size, dir, mask) => { self.execute_movem(system, target, size, dir, mask)?; }, - //Instruction::MOVEP(Register, Target, Size, Direction) => { + //Instruction::MOVEP(reg, target, size, dir) => { //}, Instruction::MOVEQ(data, reg) => { let value = sign_extend_to_long(data as u32, Size::Byte) as u32; @@ -1170,14 +1170,6 @@ fn get_msb_mask(value: u32, size: Size) -> u32 { } } -fn get_bit_op_max(size: Size) -> u32 { - match size { - Size::Byte => 8, - Size::Long => 32, - Size::Word => panic!("bit ops cannot be word size"), - } -} - fn get_bit_field_mask(offset: u32, width: u32) -> u32 { let mut mask = 0; for _ in 0..width { diff --git a/src/debugger.rs b/src/debugger.rs index e3ea599..fefb279 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -31,6 +31,7 @@ impl StackTracer { pub struct Debugger { pub last_command: Option, pub repeat: u32, + pub trace_only: bool, } @@ -39,14 +40,23 @@ impl Debugger { Self { last_command: None, repeat: 0, + trace_only: false, } } + pub fn breakpoint_occurred(&mut self) { + self.trace_only = false; + } + pub fn run_debugger(&mut self, system: &System, target: TransmutableBox) -> Result<(), Error> { let mut target = target.borrow_mut(); let debug_obj = target.as_debuggable().unwrap(); debug_obj.print_current_step(system)?; + if self.trace_only { + return Ok(()); + } + if self.repeat > 0 { self.repeat -= 1; let last_command = self.last_command.clone().unwrap(); @@ -116,6 +126,10 @@ impl Debugger { self.check_repeat_arg(args)?; return Ok(true); }, + "t" | "trace" => { + self.trace_only = true; + return Ok(true); + } //"ds" | "stack" | "dumpstack" => { // println!("Stack:"); // for addr in &self.debugger.stack_tracer.calls { diff --git a/src/system.rs b/src/system.rs index e9ba9a4..b51f599 100644 --- a/src/system.rs +++ b/src/system.rs @@ -62,6 +62,7 @@ impl System { pub fn enable_debugging(&self) { self.debug_enabled.set(true); + self.debugger.borrow_mut().breakpoint_occurred(); } pub fn disable_debugging(&self) {