Skip to content

Commit 1741f9e

Browse files
authored
Merge pull request #184 from tatsuya6502/inline-assembly-1.9
6.2. Inline Assembly (1.9)
2 parents dffdba0 + 37bd4d8 commit 1741f9e

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

1.9/ja/book/inline-assembly.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
<!-- For extremely low-level manipulations and performance reasons, one -->
55
<!-- 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. -->
87
極めて低レベルな技巧やパフォーマンス上の理由から、CPUを直接コントロールしたいと思う人もいるでしょう。
9-
Rustはそのような処理を行うためにインラインアセンブリを `asm!` マクロによってサポートしています。
10-
インラインアセンブリの構文はGCCやClangのものとおおまかに一致しています。
8+
Rustはそのような処理を行うために、インラインアセンブリを `asm!` マクロによってサポートしています。
119

1210
```ignore
1311
# // asm!(assembly template
@@ -25,19 +23,19 @@ asm!(アセンブリのテンプレート
2523

2624
<!-- Any use of `asm` is feature gated (requires `#![feature(asm)]` on the -->
2725
<!-- crate to allow) and of course requires an `unsafe` block. -->
28-
`asm` のいかなる利用もフィーチャーゲートの対象です(利用するには `#![feature(asm)]` がクレートに必要になります)、
26+
`asm` のいかなる利用もフィーチャーゲートの対象です利用するには `#![feature(asm)]` がクレートに必要になります)。
2927
そしてもちろん `unsafe` ブロックも必要です。
3028

31-
<!-- > **Note**: the examples here are given in x86/x86-64 assembly, but -->
32-
<!-- > all platforms are supported. -->
29+
<!-- &gt; **Note**: the examples here are given in x86/x86-64 assembly, but -->
30+
<!-- &gt; all platforms are supported. -->
3331
> **メモ**: ここでの例はx86/x86-64のアセンブリで示されますが、すべてのプラットフォームがサポートされています。
3432
3533
<!-- ## Assembly template -->
3634
## アセンブリテンプレート
3735

3836
<!-- The `assembly template` is the only required parameter and must be a -->
3937
<!-- literal string (i.e. `""`) -->
40-
`アセンブリテンプレート` のみが要求されるパラメータであり、文字列リテラル (例: "") である必要があります。
38+
`アセンブリテンプレート` のみが要求されるパラメータであり、文字列リテラル (例: `""`) である必要があります。
4139

4240
```rust
4341
#![feature(asm)]
@@ -66,7 +64,7 @@ fn main() {
6664

6765
<!-- Output operands, input operands, clobbers and options are all optional -->
6866
<!-- but you must add the right number of `:` if you skip them: -->
69-
出力オペランド、入力オペランド、破壊されるデータ、オプションはすべて省略可能ですが、省略する場合は `:` を正しい数書く必要が有ります
67+
出力オペランド、入力オペランド、破壊されるデータ、オプションはすべて省略可能ですが、省略する場合でも正しい数の `:` を書く必要があります
7068

7169
```rust
7270
# #![feature(asm)]
@@ -126,8 +124,8 @@ fn main() {
126124
<!-- you want, and you are required to put the specific size of the -->
127125
<!-- operand. This is useful for very low level programming, where -->
128126
<!-- which register you use is important: -->
129-
もし本当のオペランドをここで利用したい場合、 波括弧 `{}` で利用したいレジスタの周りを囲む必要があり、また、オペランドの特有のサイズを置く必要があります
130-
これは、どのレジスタを利用するかが重要になる低レベルなプログラミングで有用です
127+
もし本当のオペランドをここで利用したい場合、波括弧 `{}` で利用したいレジスタの周りを囲む必要があり、また、オペランドの特有のサイズを書く必要があります
128+
これは、どのレジスタを利用するかが重要となる、ごく低レベルのプログラミングで有用です
131129

132130
```rust
133131
# #![feature(asm)]
@@ -146,9 +144,8 @@ result
146144
<!-- different values so we use the clobbers list to indicate to the -->
147145
<!-- compiler not to assume any values loaded into those registers will -->
148146
<!-- stay valid. -->
149-
幾つかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります、
150-
そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、
151-
破壊されるデータのリストを利用します。
147+
いくつかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります。
148+
そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、破壊されるデータのリストを利用します。
152149

153150
```rust
154151
# #![feature(asm)]
@@ -164,13 +161,13 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
164161
<!-- Input and output registers need not be listed since that information -->
165162
<!-- is already communicated by the given constraints. Otherwise, any other -->
166163
<!-- registers used either implicitly or explicitly should be listed. -->
167-
入力と出力のレジスタは変更される可能性があることが制約によってすでに伝わっているためにリストに載せる必要はありません
164+
入力と出力のレジスタは変更される可能性があることが制約によってすでに伝わっているために、リストに載せる必要はありません
168165
それ以外では、その他の暗黙的、明示的に利用されるレジスタをリストに載せる必要があります。
169166

170167
<!-- If the assembly changes the condition code register `cc` should be -->
171168
<!-- specified as one of the clobbers. Similarly, if the assembly modifies -->
172169
<!-- memory, `memory` should also be specified. -->
173-
もしアセンブリが条件コードを変更する場合レジスタ `cc` も破壊されるデータのリストに指定する必要があります。
170+
もしアセンブリが条件コードを変更する場合、レジスタ `cc` も破壊されるデータのリストに指定する必要があります。
174171
同様に、もしアセンブリがメモリを変更する場合 `memory` もリストに指定する必要があります。
175172

176173
<!-- ## Options -->
@@ -180,7 +177,7 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
180177
<!-- separated literal strings (i.e. `:"foo", "bar", "baz"`). It's used to -->
181178
<!-- specify some extra info about the inline assembly: -->
182179
最後のセクション、 `options` はRust特有のものです。
183-
`options` の形式は、コンマで区切られた文字列リテラルのリスト(例: `:"foo", "bar", "baz"`)です。
180+
`options` の形式は、コンマで区切られた文字列リテラルのリスト例: `:"foo", "bar", "baz"`です。
184181
これはインラインアセンブリについての追加の情報を指定するために利用されます:
185182

186183
<!-- Current valid options are: -->
@@ -193,7 +190,7 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
193190
<!-- the compiler to insert its usual stack alignment code-->
194191
<!-- 3. *intel* - use intel syntax instead of the default AT&T.-->
195192
1. *volatile* - このオプションを指定することは、gcc/clangで `__asm__ __volatile__ (...)` を指定することと類似しています。
196-
2. *alignstack* - いくつかのインストラクションはスタックが決まった方式(例: SSE)でアラインされていることを期待しています
193+
2. *alignstack* - いくつかのインストラクションはスタックが決まった方式例: SSEでアラインされていることを期待しています
197194
このオプションを指定することはコンパイラに通常のスタックをアラインメントするコードの挿入を指示します。
198195
3. *intel* - デフォルトのAT&T構文の代わりにインテル構文を利用することを意味しています。
199196

@@ -216,7 +213,7 @@ println!("eax is currently {}", result);
216213
<!-- inline assembler expressions][llvm-docs], so be sure to check out [their -->
217214
<!-- documentation as well][llvm-docs] for more information about clobbers, -->
218215
<!-- constraints, etc. -->
219-
現在の `asm!` マクロの実装は [LLVMのインラインアセンブリ表現][llvm-docs] への直接的なバインディングです
216+
現在の `asm!` マクロの実装は [LLVMのインラインアセンブリ表現][llvm-docs] への直接的なバインディングです
220217
そのため破壊されるデータのリストや、制約、その他の情報について [LLVMのドキュメント][llvm-docs] を確認してください。
221218

222219
[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions

diff-1.6.0..1.9.0/src/doc/book/inline-assembly.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)