[英]What's use of %c in x86_64 inline assembly?
I'm reading KVM source code and confronted with x86_64 inline assembly. 我正在阅读KVM源代码,并遇到了x86_64内联汇编。 In the following code, what's use of "%c"?
在以下代码中,“%c”的用途是什么? It it new feature in x86_64 inline assembly?
它是x86_64内联汇编中的新功能吗? Any reference for new features in x86_64 inline assembly in gcc?
对gcc x86_64内联汇编中的新功能有任何参考吗?
Many thanks 非常感谢
/* Check if vmlaunch of vmresume is needed */
"cmp $0, %1 \n\t"
/* Load guest registers. Don't clobber flags. */
#ifdef CONFIG_X86_64
"mov %c[cr2](%3), %%rax \n\t"
"mov %%rax, %%cr2 \n\t"
"mov %c[rax](%3), %%rax \n\t"
"mov %c[rbx](%3), %%rbx \n\t"
"mov %c[rdx](%3), %%rdx \n\t"
You can see how this works at the end of the asm
statement: 您可以在
asm
语句的末尾看到它的工作方式:
: : "c"(vmx), "d"((unsigned long)HOST_RSP),
[launched]"i"(offsetof(struct vcpu_vmx, launched)),
[fail]"i"(offsetof(struct vcpu_vmx, fail)),
[rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])),
[rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])),
The %3
(it's %0
in the my source tree) is a reference to the local variable vmx
, and %c[rax]
, %c[cr2]
etc are the integer constant offsets of the corresponding values within the struct vcpu_vmx
that vmx
points to ( %c
meaning "constant"). %3
(在我的源代码树中为%0
)是对局部变量vmx
的引用, %c[rax]
, %c[cr2]
等是vmx
在struct vcpu_vmx
中对应值的整数常量偏移量指向( %c
表示“常量”)。
So the line: 所以这行:
mov %c[cr2](%0), %%rax
is moving the contents of vmx->vcpu.arch.cr2
into %rax
. 正在将
vmx->vcpu.arch.cr2
的内容移动到%rax
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.