Fix LSR#0
Former-commit-id: 7cfcc0b8f6e0849c9090148f2cc381b3419abd39
This commit is contained in:
parent
11219dab7e
commit
cb36db688e
|
@ -122,21 +122,24 @@ impl Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lsr(&mut self, val: u32, amount: u32, _carry_in: bool, immediate: bool) -> u32 {
|
pub fn lsr(&mut self, val: u32, amount: u32, carry_in: bool, immediate: bool) -> u32 {
|
||||||
let amount = if immediate && amount == 0 { 32 } else { amount };
|
if amount != 0 {
|
||||||
match amount {
|
match amount {
|
||||||
32 => {
|
x if x < 32 => {
|
||||||
self.bs_carry_out = val.bit(31);
|
self.bs_carry_out = (val >> (amount - 1) & 1) == 1;
|
||||||
0
|
val >> amount
|
||||||
}
|
}
|
||||||
1..=31 => {
|
_ => {
|
||||||
self.bs_carry_out = val >> (amount - 1) & 1 == 1;
|
self.bs_carry_out = false;
|
||||||
(val as u32) >> amount
|
0
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
self.bs_carry_out = false;
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
} else if immediate {
|
||||||
|
self.bs_carry_out = val.bit(31);
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
self.bs_carry_out = carry_in;
|
||||||
|
val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue