Read bits only once.
This commit is contained in:
parent
b42411e64a
commit
bb41b209a6
@ -283,8 +283,9 @@ impl mcause::R {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
/// Trap Cause
|
/// Trap Cause
|
||||||
pub fn cause(&self) -> Trap {
|
pub fn cause(&self) -> Trap {
|
||||||
let code = self.bits() & !(1 << 31);
|
let bits = self.bits();
|
||||||
match self.bits() & (1 << 31) == 1 << 31 {
|
let code = bits & !(1 << 31);
|
||||||
|
match bits & (1 << 31) == 1 << 31 {
|
||||||
true => Trap::Interrupt(Interrupt::from(code)),
|
true => Trap::Interrupt(Interrupt::from(code)),
|
||||||
false => Trap::Exception(Exception::from(code)),
|
false => Trap::Exception(Exception::from(code)),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user