Skip to content

Commit

Permalink
Privileged instructions can't trigger Trace exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stovent committed Aug 21, 2023
1 parent 365ac57 commit 68f1f5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CPU behavior is now controlled using a trait and generic member instead of features (breaking).
- Move the register access helper methods to the Registers struct.
- Status Register's default function returns a SR with value 0x2700 (breaking).
- Interrupt's exception processing sets the interrupt priority mask.
- Interrupt level 7 is non-maskable.
- Use wrapping types and methods so overflow checks can be enabled.
- Make MemoryIter generic over the underlying MemoryAccess trait object.

Expand All @@ -30,6 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix immediate Shift/Rotate count of 0 not disassembled as 8.
- Fix ABCD/NBCD/SBCD.
- Fix DIVS/DIVU changing the destination even when an overflow occured.
- Interrupt's exception processing sets the interrupt priority mask.
- Interrupt level 7 is non-maskable.
- Privileged instructions can't trigger Trace exceptions.

## [0.1.1] - 2022-08-28
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion m68000/src/interpreter_disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<CPU: CpuDetails> M68000<CPU> {
let exception = match Execute::<CPU, M>::EXECUTE[isa as usize](self, memory, &instruction) {
Ok(cycles) => {
cycle_count += cycles;
if trace {
if trace && !isa.is_privileged() {
Some(Vector::Trace as u8)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion m68000/src/interpreter_fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<CPU: CpuDetails> M68000<CPU> {
let exception = match Execute::<CPU, M>::EXECUTE[isa as usize](self, memory) {
Ok(cycles) => {
cycle_count += cycles;
if trace {
if trace && !isa.is_privileged() {
Some(Vector::Trace as u8)
} else {
None
Expand Down
16 changes: 16 additions & 0 deletions m68000/src/isa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ pub enum Isa {
_Size,
}

impl Isa {
pub const fn is_privileged(self) -> bool {
match self {
Self::Andisr => true,
Self::Eorisr => true,
Self::Movesr => true,
Self::Moveusp => true,
Self::Orisr => true,
Self::Reset => true,
Self::Rte => true,
Self::Stop => true,
_ => false,
}
}
}

impl From<u16> for Isa {
/// Returns the instruction represented by the given opcode.
fn from(opcode: u16) -> Self {
Expand Down

0 comments on commit 68f1f5a

Please sign in to comment.