You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -127,8 +127,8 @@ This is different from specifying an input and output separately in that it is g
127
127
128
128
It is also possible to specify different variables for the input and output parts of an `inout` operand:
129
129
130
-
```rust,allow_fail
131
-
# #![feature(asm)]
130
+
```rust
131
+
#![feature(asm)]
132
132
letx:u64=3;
133
133
lety:u64;
134
134
unsafe {
@@ -149,8 +149,8 @@ There is also a `inlateout` variant of this specifier.
149
149
150
150
Here is an example where `inlateout`*cannot* be used:
151
151
152
-
```rust,allow_fail
153
-
# #![feature(asm)]
152
+
```rust
153
+
#![feature(asm)]
154
154
letmuta:u64=4;
155
155
letb:u64=4;
156
156
letc:u64=4;
@@ -170,8 +170,8 @@ Here the compiler is free to allocate the same register for inputs `b` and `c` s
170
170
171
171
However the following example can use `inlateout` since the output is only modified after all input registers have been read:
172
172
173
-
```rust,allow_fail
174
-
# #![feature(asm)]
173
+
```rust
174
+
#![feature(asm)]
175
175
letmuta:u64=4;
176
176
letb:u64=4;
177
177
unsafe {
@@ -189,8 +189,8 @@ Therefore, Rust inline assembly provides some more specific constraint specifier
189
189
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`
190
190
among others can be addressed by their name.
191
191
192
-
```rust,allow_fail,no_run
193
-
# #![feature(asm)]
192
+
```rust,no_run
193
+
#![feature(asm)]
194
194
let cmd = 0xd1;
195
195
unsafe {
196
196
asm!("out 0x64, eax", in("eax") cmd);
@@ -205,8 +205,8 @@ Note that unlike other operand types, explicit register operands cannot be used
205
205
206
206
Consider this example which uses the x86 `mul` instruction:
207
207
208
-
```rust,allow_fail
209
-
# #![feature(asm)]
208
+
```rust
209
+
#![feature(asm)]
210
210
fnmul(a:u64, b:u64) ->u128 {
211
211
letlo:u64;
212
212
lethi:u64;
@@ -241,8 +241,8 @@ This state is generally referred to as being "clobbered".
241
241
We need to tell the compiler about this since it may need to save and restore this state
242
242
around the inline assembly block.
243
243
244
-
```rust,allow_fail
245
-
# #![feature(asm)]
244
+
```rust
245
+
#![feature(asm)]
246
246
letebx:u32;
247
247
letecx:u32;
248
248
@@ -271,8 +271,8 @@ However we still need to tell the compiler that `eax` and `edx` have been modifi
271
271
272
272
This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:
273
273
274
-
```rust,allow_fail
275
-
# #![feature(asm)]
274
+
```rust
275
+
#![feature(asm)]
276
276
// Multiply x by 6 using shifts and adds
277
277
letmutx:u64=4;
278
278
unsafe {
@@ -293,8 +293,8 @@ assert_eq!(x, 4 * 6);
293
293
A special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.
294
294
This allows you to call a function or access a global variable without needing to keep its address in a register.
295
295
296
-
```rust,allow_fail
297
-
# #![feature(asm)]
296
+
```rust
297
+
#![feature(asm)]
298
298
extern"C"fnfoo(arg:i32) {
299
299
println!("arg = {}", arg);
300
300
}
@@ -335,8 +335,8 @@ By default the compiler will always choose the name that refers to the full regi
335
335
336
336
This default can be overriden by using modifiers on the template string operands, just like you would with format strings:
337
337
338
-
```rust,allow_fail
339
-
# #![feature(asm)]
338
+
```rust
339
+
#![feature(asm)]
340
340
letmutx:u16=0xab;
341
341
342
342
unsafe {
@@ -360,7 +360,7 @@ You have to manually use the memory address syntax specified by the respectively
360
360
For example, in x86/x86_64 and intel assembly syntax, you should wrap inputs/outputs in `[]`
361
361
to indicate they are memory operands:
362
362
363
-
```rust,allow_fail
363
+
```rust
364
364
# #![feature(asm, llvm_asm)]
365
365
# fnload_fpu_control_word(control:u16) {
366
366
unsafe {
@@ -378,7 +378,7 @@ The compiler is allowed to instantiate multiple copies an `asm!` block, for exam
378
378
379
379
Moreover, due to [an llvm bug], you shouldn't use labels exclusively make of `0` and `1` digits, e.g. `0`, `11` or `101010`, as they may end up being interpreted as binary values.
380
380
381
-
```rust,allow_fail
381
+
```rust
382
382
#![feature(asm)]
383
383
384
384
letmuta=0;
@@ -415,8 +415,8 @@ By default, an inline assembly block is treated the same way as an external FFI
415
415
416
416
Let's take our previous example of an `add` instruction:
0 commit comments