-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rust-embedded/new-asm
Update to new assembly syntax. Create release v0.3.0.
- Loading branch information
Showing
8 changed files
with
41 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
//! Miscellaneous assembly instructions | ||
use crate::asm; | ||
|
||
/// A no-operation. Useful to prevent delay loops from being optimized away. | ||
#[inline(always)] | ||
pub fn nop() { | ||
unsafe { | ||
llvm_asm!("nop" | ||
: | ||
: | ||
: | ||
: "volatile"); | ||
asm!("nop"); | ||
} | ||
} | ||
|
||
/// A compiler fence, prevents instruction reordering. | ||
#[inline(always)] | ||
pub fn barrier() { | ||
unsafe { | ||
llvm_asm!("" ::: "memory" : "volatile"); | ||
asm!(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
//! Program counter | ||
use crate::asm; | ||
|
||
/// Reads the CPU register | ||
#[inline(always)] | ||
pub fn read() -> u16 { | ||
let r; | ||
unsafe { | ||
llvm_asm!("mov R0,$0" | ||
: "=r"(r) | ||
: | ||
: | ||
: "volatile"); | ||
asm!("mov R0, {0}", out(reg) r); | ||
} | ||
r | ||
} | ||
|
||
/// Writes `bits` to the CPU register | ||
#[inline(always)] | ||
pub unsafe fn write(bits: u16) { | ||
llvm_asm!("mov $0,R0" | ||
: | ||
: "r"(bits) | ||
: | ||
: "volatile"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
//! Main Stack Pointer | ||
use crate::asm; | ||
|
||
/// Reads the CPU register | ||
#[inline(always)] | ||
pub fn read() -> u16 { | ||
let r; | ||
unsafe { | ||
llvm_asm!("mov R1,$0" | ||
: "=r"(r) | ||
: | ||
: | ||
: "volatile"); | ||
asm!("mov R1, {0}", out(reg) r); | ||
} | ||
r | ||
} | ||
|
||
/// Writes `bits` to the CPU register | ||
#[inline(always)] | ||
pub unsafe fn write(bits: u16) { | ||
llvm_asm!("mov $0,R1" | ||
: | ||
: "r"(bits) | ||
: | ||
: "volatile"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters