谁能解释一下下面的说法?
static inline void cpu_write_dtlb(uint32_t vpn, unsigned attr)
{
asm volatile ("wdtlb %1, %0; dsync\n" :: "r" (vpn), "r" (attr));
}
最佳答案
如果您的问题是关于语法,那就是 GCC 内联汇编语言语法。
特别是,%0
和 %1
被替换为 GCC 存储 “r”
参数的寄存器。
volatile
关键字有这样的效果:
GCC’s optimizers sometimes discard asm statements if they determine there is no need for the output variables. Also, the optimizers may move code out of loops if they believe that the code will always return the same result (i.e. none of its input values change between calls). Using the
volatile
qualifier disables these optimizations.asm
statements that have no output operands, including asm goto statements, are implicitlyvolatile
.
有关此扩展语法的详细信息,请参阅 Extended Asm - Assembler Instructions with C Expression Operands 的 GCC 文档.
关于有人可以解释以下代码语句吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57307193/