msp430/
asm.rs

1//! Miscellaneous assembly instructions
2
3use crate::asm;
4
5/// A no-operation. Useful to prevent delay loops from being optimized away.
6///
7/// Unlike [barrier], this does not prevent reordering of memory access.
8#[inline(always)]
9pub fn nop() {
10    unsafe {
11        // Do not use pure because prevent nop from being removed.
12        asm!("nop", options(nomem, nostack, preserves_flags));
13    }
14}
15
16/// A compiler fence, prevents instruction reordering.
17///
18/// Unlike [nop], this does not emit machine code.
19#[inline(always)]
20pub fn barrier() {
21    unsafe {
22        // Do not use `nomem` and `readonly` because prevent preceding and subsequent memory accesses from being reordered.
23        asm!("", options(nostack, preserves_flags));
24    }
25}