Skip to content

Commit a763960

Browse files
authored
Merge pull request #1804 from ehuss/inline-assembly-let-x
Clean up some inline assembly examples
2 parents 0513e5c + 77cb46b commit a763960

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

src/inline-assembly.md

-6
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ As with format strings, positional arguments must appear before named arguments
171171

172172
```rust,compile_fail
173173
# #[cfg(target_arch = "x86_64")] {
174-
let x = 5;
175174
// Named operands need to come after positional ones
176175
unsafe { core::arch::asm!("/* {x} {} */", x = const 5, in(reg) 5); }
177176
// ERROR: positional arguments cannot follow named arguments or explicit register arguments
@@ -181,7 +180,6 @@ unsafe { core::arch::asm!("/* {x} {} */", x = const 5, in(reg) 5); }
181180

182181
```rust,compile_fail
183182
# #[cfg(target_arch = "x86_64")] {
184-
let x = 5;
185183
// We also can't put explicit registers before positional operands
186184
unsafe { core::arch::asm!("/* {} */", in("eax") 0, in(reg) 5); }
187185
// ERROR: positional arguments cannot follow named arguments or explicit register arguments
@@ -194,7 +192,6 @@ Explicit register operands cannot be used by placeholders in the template string
194192

195193
```rust,compile_fail
196194
# #[cfg(target_arch = "x86_64")] {
197-
let x = 5;
198195
// Explicit register operands don't get substituted, use `eax` explicitly in the string
199196
unsafe { core::arch::asm!("/* {} */", in("eax") 5); }
200197
// ERROR: invalid reference to argument at index 0
@@ -207,7 +204,6 @@ All other named and positional operands must appear at least once in the templat
207204

208205
```rust,compile_fail
209206
# #[cfg(target_arch = "x86_64")] {
210-
let x = 5;
211207
// We have to name all of the operands in the format string
212208
unsafe { core::arch::asm!("", in(reg) 5, x = const 5); }
213209
// ERROR: multiple unused asm arguments
@@ -407,7 +403,6 @@ Because `global_asm!` exists outside a function, it can only use `sym` and `cons
407403

408404
```rust,compile_fail
409405
# fn main() {}
410-
let x = 5;
411406
// register operands aren't allowed, since we aren't in a function
412407
# #[cfg(target_arch = "x86_64")]
413408
core::arch::global_asm!("", in(reg) 5);
@@ -469,7 +464,6 @@ Additionally, it is also a compile-time error to use overlapping registers (e.g.
469464

470465
```rust,compile_fail
471466
# #[cfg(target_arch = "x86_64")] {
472-
let x = 5;
473467
// al overlaps with ax, so we can't name both of them.
474468
unsafe { core::arch::asm!("", in("ax") 5, in("al") 4i8); }
475469
// ERROR: register `al` conflicts with register `ax`

0 commit comments

Comments
 (0)