c - 如何将 asm() 与 const char* 一起使用而不是字符串文字?
问题描述
如果我这样做:
const char *str = "some assembly instructions";
asm(str);
CLion 会说“'asm' 中的预期字符串文字”
解决方案
asm
不是在运行时调用的普通 C 函数,而是在编译时发出您指定的汇编代码的特殊指令。asm
需要在编译时知道汇编指令,这只有在参数是字符串文字时才有可能:
正确的:
asm("some instruction"); // "some instruction" is known at compile time
不正确:
asm(str); // at compile time it is potentially not known where
// str points to
结论:您不能将字符串文字以外的任何内容传递给asm
.
推荐阅读
- php - mysqli_num_rows($result)==0 返回错误
- laravel - Laravel Nova 未来指标趋势
- python - 如何使用分隔符拆分 Ansible 中的值
- java - 使用带有托管服务标识的 Spring api 获取 keyvault 机密
- python - 如何使用 sklearn 制作一维高斯混合的直方图?
- ios - 将项目添加到动态列表(苹果快捷方式)
- javascript - 为什么它只返回数组的第一个元素,而我已经打印了数组的所有值?
- r - 使用 ggplot 堆叠 bart 图 4 个变量
- arrays - 在 NumPy 中计算自协方差函数向量而不使用 np.correlate
- java - 同步 Gradle 失败:错误:对于输入字符串:“”