cortex_m/register/pc.rs
1//! Program counter
2
3#[cfg(cortex_m)]
4use core::arch::asm;
5use cortex_m_macros::asm_cfg;
6
7/// Reads the CPU register
8#[inline]
9#[asm_cfg(cortex_m)]
10pub fn read() -> u32 {
11 let r;
12 unsafe { asm!("mov {}, pc", out(reg) r, options(nomem, nostack, preserves_flags)) };
13 r
14}
15
16/// Writes `bits` to the CPU register
17#[inline]
18#[asm_cfg(cortex_m)]
19pub unsafe fn write(bits: u32) {
20 unsafe { asm!("mov pc, {}", in(reg) bits, options(nomem, nostack, preserves_flags)) };
21}