1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Link register

/// Reads the CPU register
#[inline]
pub fn read() -> u32 {
    match () {
        #[cfg(target_arch = "arm")]
        () => {
            let r: u32;
            unsafe { asm!("mov $0,R14" : "=r"(r) ::: "volatile") }
            r
        }
        #[cfg(not(target_arch = "arm"))]
        () => unimplemented!(),
    }
}

/// Writes `bits` to the CPU register
#[cfg_attr(not(target_arch = "arm"), allow(unused_variables))]
#[inline]
pub unsafe fn write(bits: u32) {
    match () {
        #[cfg(target_arch = "arm")]
        () => asm!("mov R14,$0" :: "r"(bits) :: "volatile"),
        #[cfg(not(target_arch = "arm"))]
        () => unimplemented!(),
    }
}