g++ 向我抱怨以下代码中缺少括号:
1 2 3
v v v
__asm__ volatile("inb %1, %0" : : "=a" (result) : "Nd" (portnumber) );
^ ^ ^
1 2 3
正如您所看到的,括号是匹配的,并且有三个左括号和三个右括号。
另外,为了了解更多信息,我正在关注 YouTube 教程
You have an extra :
before the output, so you ended up with your output declaration in the input part. And the reason for that error: your input operand declaration where the compiler expects the clobber list. The clobber list can only include string literals (register names and "memory"
and/or "cc"
1), not ()
.
__asm__ volatile("inb %1, %0"
: "=a" (result) // output
: "Nd" (portnumber) // input
// : "memory" // optional, clobber list
);
你可能想要一个"memory"
破坏列表以确保这是有序的。内存访问。或者不,如果你确定不需要的话。
脚注 1:x86 上的 asm 语句隐式破坏条件代码,"cc"
。如果您愿意,可以将其用于文档。但你不想要它在这里,因为inb
不触及 EFLAGS。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)