Skip to content

Commit c7665dd

Browse files
committed
Translate untranslated lines in asm.md
1 parent 5ecd550 commit c7665dd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/unsafe/asm.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,20 @@ Even though `eax` is never read we still need to tell the compiler that the regi
473473
レジスタが変更されたことをコンパイラに伝える必要があります。
474474
そのために、変数名の代わりに`_`を用いて出力を宣言し、出力の値が破棄されるということを示しています。
475475

476+
<!--
476477
This code also works around the limitation that `ebx` is a reserved register by LLVM. That means that LLVM assumes that it has full control over the register and it must be restored to its original state before exiting the asm block, so it cannot be used as an input or output **except** if the compiler uses it to fulfill a general register class (e.g. `in(reg)`). This makes `reg` operands dangerous when using reserved registers as we could unknowingly corrupt our input or output because they share the same register.
478+
-->
479+
このコードは`ebx`がLLVMによって予約されたレジスタであるという制約を回避しています。
480+
LLVMは、自身がレジスタを完全にコントロールし、
481+
アセンブリブロックを抜ける前に元の状態を復元しなくてはならないと考えています。
482+
そのため、コンパイラが`in(reg)`のような汎用レジスタクラスを満たすために使用する場合 **を除いて** `ebx`を入力や出力として利用できません。
477483

484+
<!--
478485
To work around this we use `rdi` to store the pointer to the output array, save `ebx` via `push`, read from `ebx` inside the asm block into the array and then restore `ebx` to its original state via `pop`. The `push` and `pop` use the full 64-bit `rbx` version of the register to ensure that the entire register is saved. On 32 bit targets the code would instead use `ebx` in the `push`/`pop`.
486+
-->
487+
これを回避するために、`rdi`を用いて出力の配列へのポインタを保管し、`push``ebx`を保存し、アセンブリブロック内で`ebx`から読み込んで配列に書き込み、`pop``ebx`を元の状態に戻しています。
488+
`push``pop`は完全な64ビットの`rbx`レジスタを使って、レジスタ全体を確実に保存しています。
489+
32ビットの場合、`push``pop`において`ebx`がかわりに利用されるでしょう。
479490

480491
This can also be used with a general register class to obtain a scratch register for use inside the asm code:
481492

0 commit comments

Comments
 (0)