Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline-asm: Update for new style #623

Merged
merged 3 commits into from
Jun 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions posts/inside-rust/2020-06-08-new-inline-asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,16 @@ fn main() {
for value in 0..=1024u64 {
let popcnt;
unsafe {
asm!("
popcnt {popcnt}, {v}
2:
blsi rax, {v}
jz 1f
xor {v}, rax
tzcnt rax, rax
stosb
jmp 2b
1:
",
asm!(
"popcnt {popcnt}, {v}",
"2:",
"blsi rax, {v}",
"jz 1f",
"xor {v}, rax",
"tzcnt rax, rax",
"stosb",
"jmp 2b",
"1:",
v = inout(reg) value => _,
popcnt = out(reg) popcnt,
out("rax") _, // scratch
Expand All @@ -117,7 +116,7 @@ fn main() {
```

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

Expand Down