We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 480f6d4 commit bd9ad8eCopy full SHA for bd9ad8e
src/inline-assembly.md
@@ -6,6 +6,23 @@ It can be used to embed handwritten assembly in the assembly output generated by
6
[`asm!`]: ../core/arch/macro.asm.html
7
[`global_asm!`]: ../core/arch/macro.global_asm.html
8
9
+```rust
10
+#![feature(asm)]
11
+// Multiply x by 6 using shifts and adds
12
+let mut x: u64 = 4;
13
+unsafe {
14
+ asm!(
15
+ "mov {tmp}, {x}",
16
+ "shl {tmp}, 1",
17
+ "shl {x}, 2",
18
+ "add {x}, {tmp}",
19
+ x = inout(reg) x,
20
+ tmp = out(reg) _,
21
+ );
22
+}
23
+assert_eq!(x, 4 * 6);
24
+```
25
+
26
The following ABNF specifies the general syntax:
27
28
```text
0 commit comments