mirror of
https://github.com/FranLMSP/snes.git
synced 2026-10-03 16:05:18 -04:00
LSR instruction
This commit is contained in:
@@ -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, [
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user