From bf2fa747c4e73bb9dac5bf17c21cfa66599497b0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 19 Jun 2020 20:52:29 -0700 Subject: [PATCH 1/3] inline-asm: Update for new style https://github.com/rust-lang/rust/pull/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. --- .../inside-rust/2020-06-08-new-inline-asm.md | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/posts/inside-rust/2020-06-08-new-inline-asm.md b/posts/inside-rust/2020-06-08-new-inline-asm.md index 252962876..183ad9186 100644 --- a/posts/inside-rust/2020-06-08-new-inline-asm.md +++ b/posts/inside-rust/2020-06-08-new-inline-asm.md @@ -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 From 88464666e8cc181c9e258fed17b1f2763e97c453 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 21 Jun 2020 14:22:09 -0700 Subject: [PATCH 2/3] inline-asm: Outdent --- posts/inside-rust/2020-06-08-new-inline-asm.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/posts/inside-rust/2020-06-08-new-inline-asm.md b/posts/inside-rust/2020-06-08-new-inline-asm.md index 183ad9186..2b26269f0 100644 --- a/posts/inside-rust/2020-06-08-new-inline-asm.md +++ b/posts/inside-rust/2020-06-08-new-inline-asm.md @@ -95,14 +95,14 @@ fn main() { let popcnt; unsafe { asm!( - " popcnt {popcnt}, {v}", + "popcnt {popcnt}, {v}", "2:", - " blsi rax, {v}", - " jz 1f", - " xor {v}, rax", - " tzcnt rax, rax", - " stosb", - " jmp 2b", + "blsi rax, {v}", + "jz 1f", + "xor {v}, rax", + "tzcnt rax, rax", + "stosb", + "jmp 2b", "1:", v = inout(reg) value => _, popcnt = out(reg) popcnt, From 7ce097ed5fe43e83c2d8a373f46a22e338c46115 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 21 Jun 2020 14:55:21 -0700 Subject: [PATCH 3/3] inline asm: Update play link --- posts/inside-rust/2020-06-08-new-inline-asm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/inside-rust/2020-06-08-new-inline-asm.md b/posts/inside-rust/2020-06-08-new-inline-asm.md index 2b26269f0..f2df0afca 100644 --- a/posts/inside-rust/2020-06-08-new-inline-asm.md +++ b/posts/inside-rust/2020-06-08-new-inline-asm.md @@ -116,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.)