我可以使用带有c字符串变量而不是字符串文字作为参数的asm函数吗? [英] Can I use asm function with a c - string variable instead of a string literal as an argument?

查看:118
本文介绍了我可以使用带有c字符串变量而不是字符串文字作为参数的asm函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了这样的事情:

char命令[] =某些汇编代码";

char command [] = "Some assmebly code";

asm volatile(命令);

asm volatile(command);

它没有用.具体来说,我得到以下错误: Expected string literal before command.

It didnt work. Specifically, I get the following error : Expected string literal before command.

那么,我只能在C内联汇编中使用字符串文字吗?我真的很希望能够使用上面的字符串变量.我怎样才能达到这种效果?

So, can I only use string literals with C inline assembly ? I really want to be able to use string variables like above. How can I achieve this effect ?

推荐答案

据我所知,asm代码片段是在编译阶段而不是运行时内联的.这意味着您无法做自己正在做的事情.

As far as I know asm code fragment are inlined during compilation phase, not run-time. Which means you can't do what you are doing.

按照pmg的建议,您可以通过调用外部命令来做到这一点,但这意味着用户需要安装所有工具.

As pmg suggested, you could do it by calling external commands, but it would mean user would need to have all the tools installed.

这篇关于我可以使用带有c字符串变量而不是字符串文字作为参数的asm函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆