File tree 6 files changed +22
-42
lines changed
6 files changed +22
-42
lines changed Original file line number Diff line number Diff line change 1
1
//! Miscellaneous assembly instructions
2
2
3
+ use crate :: asm;
4
+
3
5
/// A no-operation. Useful to prevent delay loops from being optimized away.
4
6
#[ inline( always) ]
5
7
pub fn nop ( ) {
6
8
unsafe {
7
- llvm_asm ! ( "nop"
8
- :
9
- :
10
- :
11
- : "volatile" ) ;
9
+ asm ! ( "nop" ) ;
12
10
}
13
11
}
14
12
15
13
/// A compiler fence, prevents instruction reordering.
16
14
#[ inline( always) ]
17
15
pub fn barrier ( ) {
18
16
unsafe {
19
- llvm_asm ! ( "" :: : "memory" : "volatile ") ;
17
+ asm ! ( "" ) ;
20
18
}
21
19
}
Original file line number Diff line number Diff line change 1
1
//! Interrupts
2
2
3
+ use crate :: asm;
4
+
3
5
pub use bare_metal:: { CriticalSection , Mutex } ;
4
6
5
7
/// Disables all interrupts
@@ -8,11 +10,7 @@ pub fn disable() {
8
10
match ( ) {
9
11
#[ cfg( target_arch = "msp430" ) ]
10
12
( ) => unsafe {
11
- llvm_asm ! ( "dint { nop"
12
- :
13
- :
14
- : "memory"
15
- : "volatile" ) ;
13
+ asm ! ( "dint {{ nop" ) ;
16
14
} ,
17
15
#[ cfg( not( target_arch = "msp430" ) ) ]
18
16
( ) => { }
@@ -31,11 +29,7 @@ pub unsafe fn enable() {
31
29
match ( ) {
32
30
#[ cfg( target_arch = "msp430" ) ]
33
31
( ) => {
34
- llvm_asm ! ( "nop { eint { nop"
35
- :
36
- :
37
- : "memory"
38
- : "volatile" ) ;
32
+ asm ! ( "nop {{ eint {{ nop" ) ;
39
33
}
40
34
#[ cfg( not( target_arch = "msp430" ) ) ]
41
35
( ) => { }
Original file line number Diff line number Diff line change 10
10
//! - Safe wrappers around assembly instructions like `nop`
11
11
12
12
#![ deny( missing_docs) ]
13
- #![ feature( llvm_asm ) ]
13
+ #![ feature( asm_experimental_arch ) ]
14
14
#![ no_std]
15
15
16
+ use core:: arch:: asm;
17
+
16
18
extern crate bare_metal;
17
19
18
20
#[ macro_use]
Original file line number Diff line number Diff line change 1
1
//! Program counter
2
2
3
+ use crate :: asm;
4
+
3
5
/// Reads the CPU register
4
6
#[ inline( always) ]
5
7
pub fn read ( ) -> u16 {
6
8
let r;
7
9
unsafe {
8
- llvm_asm ! ( "mov R0,$0"
9
- : "=r" ( r)
10
- :
11
- :
12
- : "volatile" ) ;
10
+ asm ! ( "mov R0, {0}" , out( reg) r) ;
13
11
}
14
12
r
15
13
}
16
14
17
15
/// Writes `bits` to the CPU register
18
16
#[ inline( always) ]
19
17
pub unsafe fn write ( bits : u16 ) {
20
- llvm_asm ! ( "mov $0,R0"
21
- :
22
- : "r" ( bits)
23
- :
24
- : "volatile" ) ;
18
+ asm ! ( "mov {0}, R0" , in( reg) bits) ;
25
19
}
Original file line number Diff line number Diff line change 1
1
//! Main Stack Pointer
2
2
3
+ use crate :: asm;
4
+
3
5
/// Reads the CPU register
4
6
#[ inline( always) ]
5
7
pub fn read ( ) -> u16 {
6
8
let r;
7
9
unsafe {
8
- llvm_asm ! ( "mov R1,$0"
9
- : "=r" ( r)
10
- :
11
- :
12
- : "volatile" ) ;
10
+ asm ! ( "mov R1, {0}" , out( reg) r) ;
13
11
}
14
12
r
15
13
}
16
14
17
15
/// Writes `bits` to the CPU register
18
16
#[ inline( always) ]
19
17
pub unsafe fn write ( bits : u16 ) {
20
- llvm_asm ! ( "mov $0,R1"
21
- :
22
- : "r" ( bits)
23
- :
24
- : "volatile" ) ;
18
+ asm ! ( "mov {0}, R1" , in( reg) bits) ;
25
19
}
Original file line number Diff line number Diff line change 1
1
//! Status Register
2
2
3
+ use crate :: asm;
4
+
3
5
/// Status Register
4
6
#[ derive( Clone , Copy , Debug ) ]
5
7
pub struct Sr {
@@ -77,11 +79,7 @@ impl Sr {
77
79
pub fn read ( ) -> Sr {
78
80
let r: u16 ;
79
81
unsafe {
80
- llvm_asm ! ( "mov R2, $0"
81
- : "=r" ( r)
82
- :
83
- :
84
- : "volatile" ) ;
82
+ asm ! ( "mov R2, {0}" , out( reg) r) ;
85
83
}
86
84
Sr { bits : r }
87
85
}
You can’t perform that action at this time.
0 commit comments