![](/img/trans.png)
[英]Compiler Error in inline Assembly error:- C2400: inline assembler syntax error in 'second operand'; found 'newline'
[英]LLVM complains about assembler error “Unexpected token in memory operand”
我正在做一项研究工作,以测量我机器上的内存访问时间。 为了确定我们机器上的时钟周期,我们获得了以下C片段:
static inline void getcyclecount(uint64_t* cycles)
{
__asm __volatile(
"cpuid # force all previous instruction to complete\n\t"
"rdtsc # TSC -> edx:eax \n\t"
"movl %%edx, 4(0) # store edx\n\t"
"movl %%eax, 0(0) # store eax\n\t"
: : "r"(cycles) : "eax", "ebx", "ecx", "edx");
}
但是,当我尝试编译它(XCode 4,使用“Apple LLVM编译器2.1”)时,它会在rdtsc resp的“\\ t”错误“内存操作数中的意外令牌”中产生两次。 第一个movl指令行。
我知道基本的汇编程序,但对C内联汇编程序格式没有任何线索。
你们中的任何人都知道这段代码会出现什么问题吗?
谢谢!
假设这是GCC内联汇编语法,您在内存操作数中缺少%
:
__asm __volatile(
"cpuid # force all previous instruction to complete\n\t"
"rdtsc # TSC -> edx:eax \n\t"
"movl %%edx, 4(%0) # store edx\n\t"
"movl %%eax, 0(%0) # store eax\n\t"
: : "r"(cycles) : "eax", "ebx", "ecx", "edx");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.