Skip to content

Commit ba44d8e

Browse files
committed
Translate untranslated lines in asm.md
1 parent aae9da0 commit ba44d8e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/unsafe/asm.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ The higher 64 bits are stored in `rdx` from which we fill the variable `hi`.
387387
<!--
388388
## Clobbered registers
389389
-->
390-
## 上書きされたレジスタ
390+
## クロバーレジスタ
391391

392392
<!--
393393
In many cases inline assembly will modify state that is not needed as an output.
@@ -398,7 +398,7 @@ We need to tell the compiler about this since it may need to save and restore th
398398
多くの場合、インラインレジスタは出力として必要のない状態を変更することがあります。
399399
これは普通、アセンブリでスクラッチレジスタを利用する必要があったり、
400400
私たちがこれ以上必要としていない状態を命令が変更したりするためです。
401-
これを一般的に「上書き」された状態と呼びます
401+
この状態を一般的に"クロバー"(訳注:上書き)と呼びます
402402
私たちはコンパイラにこのことを伝える必要があります。
403403
なぜならコンパイラは、インラインアセンブリブロックの前後で、
404404
この状態を保存して復元しなくてはならない可能性があるからです。
@@ -440,10 +440,10 @@ fn main() {
440440
// *ポインタそのもの* は後ろに書かれていても入力にすぎない。
441441
in("rdi") name_buf.as_mut_ptr(),
442442
// select cpuid 0, also specify eax as clobbered
443-
// cpuid 0を選択し、eaxを上書きする
443+
// cpuid 0を選択し、eaxをクロバーに指定する
444444
inout("eax") 0 => _,
445445
// cpuid clobbers these registers too
446-
// cpuidは以下のレジスタも上書きする
446+
// cpuidは以下のレジスタもクロバーする
447447
out("ecx") _,
448448
out("edx") _,
449449
);
@@ -515,9 +515,19 @@ assert_eq!(x, 4 * 6);
515515
# }
516516
```
517517

518+
<!--
518519
## Symbol operands and ABI clobbers
520+
-->
521+
## シンボル・オペランドとABIクロバー
519522

523+
<!--
520524
By default, `asm!` assumes that any register not specified as an output will have its contents preserved by the assembly code. The [`clobber_abi`] argument to `asm!` tells the compiler to automatically insert the necessary clobber operands according to the given calling convention ABI: any register which is not fully preserved in that ABI will be treated as clobbered. Multiple `clobber_abi` arguments may be provided and all clobbers from all specified ABIs will be inserted.
525+
-->
526+
デフォルトでは、`asm!`は、出力として指定されていないレジスタはアセンブリコードによって保存される、と考えます。
527+
`asm!`に渡される[`clobber_abi`]引数は、与えられた呼び出し規約のABIに従って、
528+
必要なクロバーオペランドを自動的に挿入するようコンパイラに伝えます。
529+
そのABIで完全に保存されていないレジスタは、クロバーとして扱われます。
530+
複数の `clobber_abi` 引数を指定すると、指定されたすべてのABIのクロバーが挿入されます。
521531

522532
[`clobber_abi`]: ../../reference/inline-assembly.html#abi-clobbers
523533

@@ -536,13 +546,17 @@ fn call_foo(arg: i32) -> i32 {
536546
asm!(
537547
"call {}",
538548
// Function pointer to call
549+
// 呼び出す関数ポインタ
539550
in(reg) foo,
540551
// 1st argument in rdi
552+
// 最初の引数はrdiにある
541553
in("rdi") arg,
542554
// Return value in rax
555+
// 戻り値はraxにある
543556
out("rax") result,
544557
// Mark all registers which are not preserved by the "C" calling
545558
// convention as clobbered.
559+
// "C"の呼び出し規約で保存されていないすべてのレジスタをクロバーに指定
546560
clobber_abi("C"),
547561
);
548562
result

0 commit comments

Comments
 (0)