// Increments and decrements
fn inc<AM:AddressingMode<M>>(&mut self, am: AM) {
let val = am.load(self);
let val = self.set_zn(val + 1);
am.store(self, val)
}
This is "set_zn":
fn set_zn(&mut self, val: u8) -> u8 {
self.set_flag(ZERO_FLAG, val == 0);
self.set_flag(NEGATIVE_FLAG, (val & 0x80) != 0);
val
}
I can't see how this would handle a increment of value 255 without panicking? Seeing that there's been no commits in 3 years, perhaps Rust handled overflows differently back then? (Just getting started, writing an emulator in Rust to get to know the language)
For example, here's how "inc" is implemented:
This is "set_zn":
I can't see how this would handle a increment of value 255 without panicking? Seeing that there's been no commits in 3 years, perhaps Rust handled overflows differently back then? (Just getting started, writing an emulator in Rust to get to know the language)