Merge pull request #32 from omarandlorraine/stackfix

Stackfix
This commit is contained in:
Matthias 2021-01-30 23:49:57 +01:00 committed by GitHub
commit a6eae6f2b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -1361,5 +1361,11 @@ mod tests {
}
}
}
}
#[test]
fn stack_underflow() {
let mut cpu = CPU::new();
let _val: u8 = cpu.pull_from_stack();
}
}

View File

@ -154,11 +154,11 @@ impl StackPointer {
// JAM: FIXME: Should we prevent overflow here? What would a 6502 do?
pub fn decrement(&mut self) {
self.0 -= 1;
self.0 = self.0.wrapping_sub(1);
}
pub fn increment(&mut self) {
self.0 += 1;
self.0 = self.0.wrapping_add(1);
}
}