3
3
4
4
<!-- For extremely low-level manipulations and performance reasons, one -->
5
5
<!-- might wish to control the CPU directly. Rust supports using inline -->
6
- <!-- assembly to do this via the `asm!` macro. The syntax roughly matches -->
7
- <!-- that of GCC & Clang: -->
6
+ <!-- assembly to do this via the `asm!` macro.
8
7
極めて低レベルな技巧やパフォーマンス上の理由から、CPUを直接コントロールしたいと思う人もいるでしょう。
9
8
Rustはそのような処理を行うためにインラインアセンブリを `asm!` マクロによってサポートしています。
10
- インラインアセンブリの構文はGCCやClangのものとおおまかに一致しています。
11
9
12
10
```ignore
13
11
# // asm!(assembly template
@@ -25,11 +23,11 @@ asm!(アセンブリのテンプレート
25
23
26
24
<!-- Any use of `asm` is feature gated (requires `#![feature(asm)]` on the -->
27
25
<!-- crate to allow) and of course requires an `unsafe` block. -->
28
- ` asm ` のいかなる利用もフィーチャーゲートの対象です(利用するには ` #![feature(asm)] ` がクレートに必要になります)、
26
+ ` asm ` のいかなる利用もフィーチャーゲートの対象です(利用するには ` #![feature(asm)] ` がクレートに必要になります)。
29
27
そしてもちろん ` unsafe ` ブロックも必要です。
30
28
31
- <!-- > **Note**: the examples here are given in x86/x86-64 assembly, but -->
32
- <!-- > all platforms are supported. -->
29
+ <!-- > **Note**: the examples here are given in x86/x86-64 assembly, but -->
30
+ <!-- > all platforms are supported. -->
33
31
> ** メモ** : ここでの例はx86/x86-64のアセンブリで示されますが、すべてのプラットフォームがサポートされています。
34
32
35
33
<!-- ## Assembly template -->
@@ -146,9 +144,8 @@ result
146
144
<!-- different values so we use the clobbers list to indicate to the -->
147
145
<!-- compiler not to assume any values loaded into those registers will -->
148
146
<!-- stay valid. -->
149
- 幾つかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります、
150
- そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、
151
- 破壊されるデータのリストを利用します。
147
+ 幾つかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります。
148
+ そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、破壊されるデータのリストを利用します。
152
149
153
150
``` rust
154
151
# #![feature(asm)]
@@ -193,7 +190,7 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
193
190
<!-- the compiler to insert its usual stack alignment code-->
194
191
<!-- 3. *intel* - use intel syntax instead of the default AT&T.-->
195
192
1 . * volatile* - このオプションを指定することは、gcc/clangで ` __asm__ __volatile__ (...) ` を指定することと類似しています。
196
- 2 . * alignstack* - いくつかのインストラクションはスタックが決まった方式(例: SSE)でアラインされていることを期待しています、
193
+ 2 . * alignstack* - いくつかのインストラクションはスタックが決まった方式(例: SSE)でアラインされていることを期待しています。
197
194
このオプションを指定することはコンパイラに通常のスタックをアラインメントするコードの挿入を指示します。
198
195
3 . * intel* - デフォルトのAT&T構文の代わりにインテル構文を利用することを意味しています。
199
196
@@ -216,7 +213,7 @@ println!("eax is currently {}", result);
216
213
<!-- inline assembler expressions][llvm-docs], so be sure to check out [their -->
217
214
<!-- documentation as well][llvm-docs] for more information about clobbers, -->
218
215
<!-- constraints, etc. -->
219
- 現在の ` asm! ` マクロの実装は [ LLVMのインラインアセンブリ表現] [ llvm-docs ] への直接的なバインディングです、
216
+ 現在の ` asm! ` マクロの実装は [ LLVMのインラインアセンブリ表現] [ llvm-docs ] への直接的なバインディングです。
220
217
そのため破壊されるデータのリストや、制約、その他の情報について [ LLVMのドキュメント] [ llvm-docs ] を確認してください。
221
218
222
219
[ llvm-docs ] : http://llvm.org/docs/LangRef.html#inline-assembler-expressions
0 commit comments