LSR instruction

This commit is contained in:
2022-11-27 09:08:44 -05:00
parent 9980ce2c9f
commit 253201c6c5
3 changed files with 68 additions and 0 deletions
+9
View File
@@ -109,6 +109,15 @@ pub fn asl<T: SnesNum>(target: T) -> (T, [Flags; 3]) {
])
}
pub fn lsr<T: SnesNum>(target: T) -> (T, [Flags; 3]) {
let result = target.lsr();
(result, [
Negative(false),
Zero(result.is_zero()),
Carry(result.to_u32() & 1 == 1), // High bit becomes carry
])
}
pub fn eor<T: SnesNum>(target: T, value: T) -> (T, [Flags; 2]) {
let result = target.xor(value);
(result, [
+5
View File
@@ -6,6 +6,7 @@ pub trait SnesNum: Copy + Clone + Sized + Eq + PartialEq {
fn sbc_snes(&self, v: Self, carry: bool) -> Self;
fn and(&self, v: Self) -> Self;
fn asl(&self) -> Self;
fn lsr(&self) -> Self;
fn xor(&self, v: Self) -> Self;
fn is_negative(&self) -> bool;
fn is_zero(&self) -> bool;
@@ -68,6 +69,10 @@ macro_rules! define_impl {
(* self) << 1
}
fn lsr(&self) -> $t {
(* self) >> 1
}
fn xor(&self, v: $t) -> $t {
(* self) ^ v
}