#[derive(Clone, Copy, Debug)]
pub struct Sr {
bits: u16,
}
impl Sr {
pub fn bits(&self) -> u16 {
self.bits
}
pub fn c(&self) -> bool {
self.bits & (1 << 0) != 0
}
pub fn z(&self) -> bool {
self.bits & (1 << 1) != 0
}
pub fn n(&self) -> bool {
self.bits & (1 << 2) != 0
}
pub fn gie(&self) -> bool {
self.bits & (1 << 3) != 0
}
pub fn cpuoff(&self) -> bool {
self.bits & (1 << 4) != 0
}
pub fn oscoff(&self) -> bool {
self.bits & (1 << 5) != 0
}
pub fn scg0(&self) -> bool {
self.bits & (1 << 6) != 0
}
pub fn scg1(&self) -> bool {
self.bits & (1 << 7) != 0
}
pub fn v(&self) -> bool {
self.bits & (1 << 8) != 0
}
}
#[inline(always)]
pub fn read() -> Sr {
let r: u16;
unsafe {
asm!("mov R2, $0"
: "=r"(r)
:
:
: "volatile");
}
Sr { bits: r }
}