@@ -10,24 +10,34 @@ Rustはそのような処理を行うためにインラインアセンブリを
1010インラインアセンブリの構文はGCCやClangのものとおおまかに一致しています。
1111
1212``` ignore
13- asm!(assembly template
14- : output operands
15- : input operands
16- : clobbers
17- : options
13+ # // asm!(assembly template
14+ asm!(アセンブリのテンプレート
15+ # // : output operands
16+ : 出力オペランド
17+ # // : input operands
18+ : 入力オペランド
19+ # // : clobbers
20+ : 破壊されるデータ
21+ # // : options
22+ : オプション
1823 );
1924```
2025
21- Any use of ` asm ` is feature gated (requires ` #![feature(asm)] ` on the
22- crate to allow) and of course requires an ` unsafe ` block.
26+ <!-- Any use of `asm` is feature gated (requires `#![feature(asm)]` on the -->
27+ <!-- crate to allow) and of course requires an `unsafe` block. -->
28+ ` asm ` のいかなる利用もフィーチャーゲートの対象です(利用するには ` #![feature(asm)] ` がクレートに必要になります)、
29+ そしてもちろん ` unsafe ` ブロックも必要です。
2330
24- > ** Note** : the examples here are given in x86/x86-64 assembly, but
25- > all platforms are supported.
31+ <!-- > **Note**: the examples here are given in x86/x86-64 assembly, but -->
32+ <!-- > all platforms are supported. -->
33+ > ** メモ** : ここでの例はx86/x86-64のアセンブリで示されますが、すべてのプラットフォームがサポートされています。
2634
27- ## Assembly template
35+ <!-- ## Assembly template -->
36+ ## アセンブリテンプレート
2837
29- The ` assembly template ` is the only required parameter and must be a
30- literal string (i.e. ` "" ` )
38+ <!-- The `assembly template` is the only required parameter and must be a -->
39+ <!-- literal string (i.e. `""`) -->
40+ ` アセンブリテンプレート ` のみが要求されるパラメータであり、文字列リテラルである必要があります。
3141
3242``` rust
3343#![feature(asm)]
@@ -39,7 +49,8 @@ fn foo() {
3949 }
4050}
4151
42- // other platforms
52+ # // // other platforms
53+ // その他のプラットフォーム
4354#[cfg(not(any(target_arch = " x86" , target_arch = " x86_64" )))]
4455fn foo () { /* ... */ }
4556
@@ -50,10 +61,12 @@ fn main() {
5061}
5162```
5263
53- (The ` feature(asm) ` and ` #[cfg] ` s are omitted from now on.)
64+ <!-- (The `feature(asm)` and `#[cfg]`s are omitted from now on.) -->
65+ 以後は、 ` feature(asm) ` と ` #[cfg] ` は省略して示します。
5466
55- Output operands, input operands, clobbers and options are all optional
56- but you must add the right number of ` : ` if you skip them:
67+ <!-- Output operands, input operands, clobbers and options are all optional -->
68+ <!-- but you must add the right number of `:` if you skip them: -->
69+ 出力オペランド、入力オペランド、破壊されるデータ、オプションはすべて省略可能ですが、省略する場合は ` : ` を正しい数書く必要が有ります。
5770
5871``` rust
5972# #![feature(asm)]
@@ -67,7 +80,8 @@ asm!("xor %eax, %eax"
6780# } }
6881```
6982
70- Whitespace also doesn't matter:
83+ <!-- Whitespace also doesn't matter: -->
84+ 空白も必要ではありません:
7185
7286``` rust
7387# #![feature(asm)]
@@ -77,11 +91,14 @@ asm!("xor %eax, %eax" ::: "{eax}");
7791# } }
7892```
7993
80- ## Operands
94+ <!-- ## Operands -->
95+ ## オペランド
8196
82- Input and output operands follow the same format: `:
83- "constraints1"(expr1), "constraints2"(expr2), ..."`. Output operand
84- expressions must be mutable lvalues, or not yet assigned:
97+ <!-- Input and output operands follow the same format: `: -->
98+ <!-- "constraints1"(expr1), "constraints2"(expr2), ..."`. Output operand -->
99+ <!-- expressions must be mutable lvalues, or not yet assigned: -->
100+ 入力と出力のオペランドは、 ` : "制約1"(式1), "制約2"(式2), ... ` というフォーマットに従います。
101+ 出力オペランドの式は変更可能な左辺値か、アサインされていない状態でなければなりません。
85102
86103``` rust
87104# #![feature(asm)]
@@ -104,11 +121,13 @@ fn main() {
104121}
105122```
106123
107- If you would like to use real operands in this position, however,
108- you are required to put curly braces ` {} ` around the register that
109- you want, and you are required to put the specific size of the
110- operand. This is useful for very low level programming, where
111- which register you use is important:
124+ <!-- If you would like to use real operands in this position, however, -->
125+ <!-- you are required to put curly braces `{}` around the register that -->
126+ <!-- you want, and you are required to put the specific size of the -->
127+ <!-- operand. This is useful for very low level programming, where -->
128+ <!-- which register you use is important: -->
129+ もし本当のオペランドをここで利用したい場合、 波括弧 ` {} ` で利用したいレジスタの周りを囲む必要があり、また、オペランドの特有のサイズを置く必要があります。
130+ これは、どのレジスタを利用するかが重要になる低レベルなプログラミングで有用です。
112131
113132``` rust
114133# #![feature(asm)]
@@ -120,44 +139,63 @@ result
120139# }
121140```
122141
123- ## Clobbers
142+ <!-- ## Clobbers -->
143+ ## 破壊されるデータ
124144
125- Some instructions modify registers which might otherwise have held
126- different values so we use the clobbers list to indicate to the
127- compiler not to assume any values loaded into those registers will
128- stay valid.
145+ <!-- Some instructions modify registers which might otherwise have held -->
146+ <!-- different values so we use the clobbers list to indicate to the -->
147+ <!-- compiler not to assume any values loaded into those registers will -->
148+ <!-- stay valid. -->
149+ 幾つかのインストラクションは異なる値を持っている可能性のあるレジスタを変更する事があります、
150+ そのため、コンパイラがそれらのレジスタに格納された値が処理後にも有効であると思わないように、
151+ 破壊されるデータのリストを利用します。
129152
130153``` rust
131154# #![feature(asm)]
132155# #[cfg(any(target_arch = " x86" , target_arch = " x86_64" ))]
133156# fn main () { unsafe {
134- // Put the value 0x200 in eax
135- asm! (" mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : " {eax}" );
157+ # // // Put the value 0x200 in eax
158+ // eaxに0x200を格納します
159+ # // asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "{eax}");
160+ asm! (" mov $$0x200, %eax" : /* 出力なし */ : /* 入力無し */ : " {eax}" );
136161# } }
137162```
138163
139- Input and output registers need not be listed since that information
140- is already communicated by the given constraints. Otherwise, any other
141- registers used either implicitly or explicitly should be listed.
142-
143- If the assembly changes the condition code register ` cc ` should be
144- specified as one of the clobbers. Similarly, if the assembly modifies
145- memory, ` memory ` should also be specified.
146-
147- ## Options
148-
149- The last section, ` options ` is specific to Rust. The format is comma
150- separated literal strings (i.e. ` :"foo", "bar", "baz" ` ). It's used to
151- specify some extra info about the inline assembly:
152-
153- Current valid options are:
154-
155- 1 . * volatile* - specifying this is analogous to
156- ` __asm__ __volatile__ (...) ` in gcc/clang.
157- 2 . * alignstack* - certain instructions expect the stack to be
158- aligned a certain way (i.e. SSE) and specifying this indicates to
159- the compiler to insert its usual stack alignment code
160- 3 . * intel* - use intel syntax instead of the default AT&T.
164+ <!-- Input and output registers need not be listed since that information -->
165+ <!-- is already communicated by the given constraints. Otherwise, any other -->
166+ <!-- registers used either implicitly or explicitly should be listed. -->
167+ 入力と出力のレジスタは変更される可能性があることが制約によってすでに伝わっているためにリストに載せる必要はありません。
168+ その以外では、その他の暗黙的、明示的に利用されるレジスタをリストに載せる必要があります。
169+
170+ <!-- If the assembly changes the condition code register `cc` should be -->
171+ <!-- specified as one of the clobbers. Similarly, if the assembly modifies -->
172+ <!-- memory, `memory` should also be specified. -->
173+ もしアセンブリが条件コードを変更する場合レジスタ ` cc ` も破壊されるデータのリストに指定する必要があります。
174+ 同様に、もしアセンブリがメモリを変更する場合 ` memory ` もリストに指定する必要があります。
175+
176+ <!-- ## Options -->
177+ ## オプション
178+
179+ <!-- The last section, `options` is specific to Rust. The format is comma -->
180+ <!-- separated literal strings (i.e. `:"foo", "bar", "baz"`). It's used to -->
181+ <!-- specify some extra info about the inline assembly: -->
182+ 最後のセクション、 ` options ` はRust特有のものです。
183+ ` options ` の形式は、コンマで区切られた文字列リテラルのリスト(例: ` :"foo", "bar", "baz" ` )です。
184+ これはインラインアセンブリについての追加の情報を指定するために利用されます:
185+
186+ <!-- Current valid options are: -->
187+ 現在有効なオプションは以下の通りです:
188+
189+ <!-- 1. *volatile* - specifying this is analogous to-->
190+ <!-- `__asm__ __volatile__ (...)` in gcc/clang.-->
191+ <!-- 2. *alignstack* - certain instructions expect the stack to be-->
192+ <!-- aligned a certain way (i.e. SSE) and specifying this indicates to-->
193+ <!-- the compiler to insert its usual stack alignment code-->
194+ <!-- 3. *intel* - use intel syntax instead of the default AT&T.-->
195+ 1 . * volatile* - このオプションを指定することは、gcc/clangで ` __asm__ __volatile__ (...) ` を指定することと類似しています。
196+ 2 . * alignstack* - いくつかのインストラクションはスタックが決まった方式(例: SSE)でアラインされていることを期待しています、
197+ このオプションを指定することはコンパイラに通常のスタックをアラインメントするコードの挿入を指示します。
198+ 3 . * intel* - デフォルトのAT&T構文の代わりにインテル構文を利用することを意味しています。
161199
162200``` rust
163201# #![feature(asm)]
@@ -171,11 +209,14 @@ println!("eax is currently {}", result);
171209# }
172210```
173211
174- ## More Information
212+ <!-- ## More Information -->
213+ ## さらなる情報
175214
176- The current implementation of the ` asm! ` macro is a direct binding to [ LLVM's
177- inline assembler expressions] [ llvm-docs ] , so be sure to check out [ their
178- documentation as well] [ llvm-docs ] for more information about clobbers,
179- constraints, etc.
215+ <!-- The current implementation of the `asm!` macro is a direct binding to [LLVM's -->
216+ <!-- inline assembler expressions][llvm-docs], so be sure to check out [their -->
217+ <!-- documentation as well][llvm-docs] for more information about clobbers, -->
218+ <!-- constraints, etc. -->
219+ 現在の ` asm! ` マクロの実装は [ LLVMのインラインアセンブリ表現] [ llvm-docs ] への直接的なバインディングです、
220+ そのため破壊されるデータのリストや、制約、その他の情報について [ LLVMのドキュメント] [ llvm-docs ] を確認してください。
180221
181222[ llvm-docs ] : http://llvm.org/docs/LangRef.html#inline-assembler-expressions
0 commit comments