Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 33ea5cb

Browse files
joshtriplettjackh726
authored andcommittedJul 26, 2021
inline-asm: Update for new style (rust-lang#623)
* inline-asm: Update for new style rust-lang/rust#73364 implemented support for providing multiple lines of assembly as separate arguments to `asm!`; update the blog post to use that new syntax, so that people who find it will use that style as an example. * inline-asm: Outdent * inline asm: Update play link
1 parent 5684ffb commit 33ea5cb

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed
 

‎posts/inside-rust/2020-06-08-new-inline-asm.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,16 @@ fn main() {
9494
for value in 0..=1024u64 {
9595
let popcnt;
9696
unsafe {
97-
asm!("
98-
popcnt {popcnt}, {v}
99-
2:
100-
blsi rax, {v}
101-
jz 1f
102-
xor {v}, rax
103-
tzcnt rax, rax
104-
stosb
105-
jmp 2b
106-
1:
107-
",
97+
asm!(
98+
"popcnt {popcnt}, {v}",
99+
"2:",
100+
"blsi rax, {v}",
101+
"jz 1f",
102+
"xor {v}, rax",
103+
"tzcnt rax, rax",
104+
"stosb",
105+
"jmp 2b",
106+
"1:",
108107
v = inout(reg) value => _,
109108
popcnt = out(reg) popcnt,
110109
out("rax") _, // scratch
@@ -117,7 +116,7 @@ fn main() {
117116
```
118117

119118
(You can [try this example on the
120-
playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=38874735e48aa20289f23f5a3cbeae0c).
119+
playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=894a407f0fe858559aa378edf6ec4801).
121120
Note that this code serves to demonstrate inline assembly, not to demonstrate
122121
an efficient implementation of any particular algorithm.)
123122

0 commit comments

Comments
 (0)
Please sign in to comment.