Skip to content

Commit 1f7de3f

Browse files
author
Timothée Delabrouille
committed
set allow_fail back on each example
1 parent 4f8dbf6 commit 1f7de3f

File tree

1 file changed

+17
-17
lines changed
  • src/doc/unstable-book/src/library-features

1 file changed

+17
-17
lines changed

src/doc/unstable-book/src/library-features/asm.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Inline assembly is currently supported on the following architectures:
3434

3535
Let us start with the simplest possible example:
3636

37-
```rust
37+
```rust,allow_fail
3838
#![feature(asm)]
3939
unsafe {
4040
asm!("nop");
@@ -51,7 +51,7 @@ in the first argument of the `asm!` macro as a string literal.
5151
Now inserting an instruction that does nothing is rather boring. Let us do something that
5252
actually acts on data:
5353

54-
```rust
54+
```rust,allow_fail
5555
#![feature(asm)]
5656
let x: u64;
5757
unsafe {
@@ -73,7 +73,7 @@ the template and will read the variable from there after the inline assembly fin
7373

7474
Let us see another example that also uses an input:
7575

76-
```rust
76+
```rust,allow_fail
7777
#![feature(asm)]
7878
let i: u64 = 3;
7979
let o: u64;
@@ -113,7 +113,7 @@ readability, and allows reordering instructions without changing the argument or
113113

114114
We can further refine the above example to avoid the `mov` instruction:
115115

116-
```rust
116+
```rust,allow_fail
117117
#![feature(asm)]
118118
let mut x: u64 = 3;
119119
unsafe {
@@ -127,7 +127,7 @@ This is different from specifying an input and output separately in that it is g
127127

128128
It is also possible to specify different variables for the input and output parts of an `inout` operand:
129129

130-
```rust
130+
```rust,allow_fail
131131
#![feature(asm)]
132132
let x: u64 = 3;
133133
let y: u64;
@@ -149,7 +149,7 @@ There is also a `inlateout` variant of this specifier.
149149

150150
Here is an example where `inlateout` *cannot* be used:
151151

152-
```rust
152+
```rust,allow_fail
153153
#![feature(asm)]
154154
let mut a: u64 = 4;
155155
let b: u64 = 4;
@@ -170,7 +170,7 @@ Here the compiler is free to allocate the same register for inputs `b` and `c` s
170170

171171
However the following example can use `inlateout` since the output is only modified after all input registers have been read:
172172

173-
```rust
173+
```rust,allow_fail
174174
#![feature(asm)]
175175
let mut a: u64 = 4;
176176
let b: u64 = 4;
@@ -189,7 +189,7 @@ Therefore, Rust inline assembly provides some more specific constraint specifier
189189
While `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`
190190
among others can be addressed by their name.
191191

192-
```rust,no_run
192+
```rust,allow_fail,no_run
193193
#![feature(asm)]
194194
let cmd = 0xd1;
195195
unsafe {
@@ -205,7 +205,7 @@ Note that unlike other operand types, explicit register operands cannot be used
205205

206206
Consider this example which uses the x86 `mul` instruction:
207207

208-
```rust
208+
```rust,allow_fail
209209
#![feature(asm)]
210210
fn mul(a: u64, b: u64) -> u128 {
211211
let lo: u64;
@@ -241,7 +241,7 @@ This state is generally referred to as being "clobbered".
241241
We need to tell the compiler about this since it may need to save and restore this state
242242
around the inline assembly block.
243243

244-
```rust
244+
```rust,allow_fail
245245
#![feature(asm)]
246246
let ebx: u32;
247247
let ecx: u32;
@@ -271,7 +271,7 @@ However we still need to tell the compiler that `eax` and `edx` have been modifi
271271

272272
This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:
273273

274-
```rust
274+
```rust,allow_fail
275275
#![feature(asm)]
276276
// Multiply x by 6 using shifts and adds
277277
let mut x: u64 = 4;
@@ -293,7 +293,7 @@ assert_eq!(x, 4 * 6);
293293
A special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.
294294
This allows you to call a function or access a global variable without needing to keep its address in a register.
295295

296-
```rust
296+
```rust,allow_fail
297297
#![feature(asm)]
298298
extern "C" fn foo(arg: i32) {
299299
println!("arg = {}", arg);
@@ -335,7 +335,7 @@ By default the compiler will always choose the name that refers to the full regi
335335

336336
This default can be overriden by using modifiers on the template string operands, just like you would with format strings:
337337

338-
```rust
338+
```rust,allow_fail
339339
#![feature(asm)]
340340
let mut x: u16 = 0xab;
341341
@@ -360,8 +360,8 @@ You have to manually use the memory address syntax specified by the respectively
360360
For example, in x86/x86_64 and intel assembly syntax, you should wrap inputs/outputs in `[]`
361361
to indicate they are memory operands:
362362

363-
```rust
364-
# #![feature(asm, llvm_asm)]
363+
```rust,allow_fail
364+
#![feature(asm, llvm_asm)]
365365
# fn load_fpu_control_word(control: u16) {
366366
unsafe {
367367
asm!("fldcw [{}]", in(reg) &control, options(nostack));
@@ -378,7 +378,7 @@ The compiler is allowed to instantiate multiple copies an `asm!` block, for exam
378378

379379
Moreover, due to [an llvm bug], you shouldn't use labels exclusively made of `0` and `1` digits, e.g. `0`, `11` or `101010`, as they may end up being interpreted as binary values.
380380

381-
```rust
381+
```rust,allow_fail
382382
#![feature(asm)]
383383
384384
let mut a = 0;
@@ -415,7 +415,7 @@ By default, an inline assembly block is treated the same way as an external FFI
415415

416416
Let's take our previous example of an `add` instruction:
417417

418-
```rust
418+
```rust,allow_fail
419419
#![feature(asm)]
420420
let mut a: u64 = 4;
421421
let b: u64 = 4;

0 commit comments

Comments
 (0)