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.
6
+ <!-- assembly to do this via the `asm!` macro. -->
7
7
極めて低レベルな技巧やパフォーマンス上の理由から、CPUを直接コントロールしたいと思う人もいるでしょう。
8
- Rustはそのような処理を行うためにインラインアセンブリを `asm!` マクロによってサポートしています。
8
+ Rustはそのような処理を行うために、インラインアセンブリを ` asm! ` マクロによってサポートしています。
9
9
10
10
``` ignore
11
11
# // asm!(assembly template
@@ -23,7 +23,7 @@ asm!(アセンブリのテンプレート
23
23
24
24
<!-- Any use of `asm` is feature gated (requires `#![feature(asm)]` on the -->
25
25
<!-- crate to allow) and of course requires an `unsafe` block. -->
26
- ` asm ` のいかなる利用もフィーチャーゲートの対象です( 利用するには ` #![feature(asm)] ` がクレートに必要になります) 。
26
+ ` asm ` のいかなる利用もフィーチャーゲートの対象です( 利用するには ` #![feature(asm)] ` がクレートに必要になります) 。
27
27
そしてもちろん ` unsafe ` ブロックも必要です。
28
28
29
29
<!-- > **Note**: the examples here are given in x86/x86-64 assembly, but -->
@@ -35,7 +35,7 @@ asm!(アセンブリのテンプレート
35
35
36
36
<!-- The `assembly template` is the only required parameter and must be a -->
37
37
<!-- literal string (i.e. `""`) -->
38
- ` アセンブリテンプレート ` のみが要求されるパラメータであり、文字列リテラル (例: "" ) である必要があります。
38
+ ` アセンブリテンプレート ` のみが要求されるパラメータであり、文字列リテラル (例: ` "" ` ) である必要があります。
39
39
40
40
``` rust
41
41
#![feature(asm)]
@@ -64,7 +64,7 @@ fn main() {
64
64
65
65
<!-- Output operands, input operands, clobbers and options are all optional -->
66
66
<!-- but you must add the right number of `:` if you skip them: -->
67
- 出力オペランド、入力オペランド、破壊されるデータ、オプションはすべて省略可能ですが、省略する場合は ` : ` を正しい数書く必要が有ります 。
67
+ 出力オペランド、入力オペランド、破壊されるデータ、オプションはすべて省略可能ですが、省略する場合でも正しい数の ` : ` を書く必要があります 。
68
68
69
69
``` rust
70
70
# #![feature(asm)]
@@ -124,8 +124,8 @@ fn main() {
124
124
<!-- you want, and you are required to put the specific size of the -->
125
125
<!-- operand. This is useful for very low level programming, where -->
126
126
<!-- which register you use is important: -->
127
- もし本当のオペランドをここで利用したい場合、 波括弧 ` {} ` で利用したいレジスタの周りを囲む必要があり、また、オペランドの特有のサイズを置く必要があります 。
128
- これは、どのレジスタを利用するかが重要になる低レベルなプログラミングで有用です 。
127
+ もし本当のオペランドをここで利用したい場合、波括弧 ` {} ` で利用したいレジスタの周りを囲む必要があり、また、オペランドの特有のサイズを書く必要があります 。
128
+ これは、どのレジスタを利用するかが重要となる、ごく低レベルのプログラミングで有用です 。
129
129
130
130
``` rust
131
131
# #![feature(asm)]
@@ -144,7 +144,7 @@ result
144
144
<!-- different values so we use the clobbers list to indicate to the -->
145
145
<!-- compiler not to assume any values loaded into those registers will -->
146
146
<!-- stay valid. -->
147
- 幾つかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります 。
147
+ いくつかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります 。
148
148
そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、破壊されるデータのリストを利用します。
149
149
150
150
``` rust
@@ -161,13 +161,13 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
161
161
<!-- Input and output registers need not be listed since that information -->
162
162
<!-- is already communicated by the given constraints. Otherwise, any other -->
163
163
<!-- registers used either implicitly or explicitly should be listed. -->
164
- 入力と出力のレジスタは変更される可能性があることが制約によってすでに伝わっているためにリストに載せる必要はありません 。
164
+ 入力と出力のレジスタは変更される可能性があることが制約によってすでに伝わっているために、リストに載せる必要はありません 。
165
165
それ以外では、その他の暗黙的、明示的に利用されるレジスタをリストに載せる必要があります。
166
166
167
167
<!-- If the assembly changes the condition code register `cc` should be -->
168
168
<!-- specified as one of the clobbers. Similarly, if the assembly modifies -->
169
169
<!-- memory, `memory` should also be specified. -->
170
- もしアセンブリが条件コードを変更する場合レジスタ ` cc ` も破壊されるデータのリストに指定する必要があります。
170
+ もしアセンブリが条件コードを変更する場合、レジスタ ` cc ` も破壊されるデータのリストに指定する必要があります。
171
171
同様に、もしアセンブリがメモリを変更する場合 ` memory ` もリストに指定する必要があります。
172
172
173
173
<!-- ## Options -->
@@ -177,7 +177,7 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
177
177
<!-- separated literal strings (i.e. `:"foo", "bar", "baz"`). It's used to -->
178
178
<!-- specify some extra info about the inline assembly: -->
179
179
最後のセクション、 ` options ` はRust特有のものです。
180
- ` options ` の形式は、コンマで区切られた文字列リテラルのリスト( 例: ` :"foo", "bar", "baz" ` ) です。
180
+ ` options ` の形式は、コンマで区切られた文字列リテラルのリスト( 例: ` :"foo", "bar", "baz" ` ) です。
181
181
これはインラインアセンブリについての追加の情報を指定するために利用されます:
182
182
183
183
<!-- Current valid options are: -->
@@ -190,7 +190,7 @@ asm!("mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : "{eax}");
190
190
<!-- the compiler to insert its usual stack alignment code-->
191
191
<!-- 3. *intel* - use intel syntax instead of the default AT&T.-->
192
192
1 . * volatile* - このオプションを指定することは、gcc/clangで ` __asm__ __volatile__ (...) ` を指定することと類似しています。
193
- 2 . * alignstack* - いくつかのインストラクションはスタックが決まった方式( 例: SSE) でアラインされていることを期待しています。
193
+ 2 . * alignstack* - いくつかのインストラクションはスタックが決まった方式( 例: SSE) でアラインされていることを期待しています。
194
194
このオプションを指定することはコンパイラに通常のスタックをアラインメントするコードの挿入を指示します。
195
195
3 . * intel* - デフォルトのAT&T構文の代わりにインテル構文を利用することを意味しています。
196
196
0 commit comments