GCC内联汇编:跳转到模块外部的标签 [英] GCC Inline Assembly: Jump to label outside block
本文介绍了GCC内联汇编:跳转到模块外部的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MSVC下使用嵌入式程序集时,可以通过引用C/C ++代码中的标签来跳出程序集块,如
When using inline assembly under MSVC, one is allowed to jump outside of the assembly block by referencing a label in the C/C++ code, as explained in this MSDN article.
在GCC下使用内联汇编可以做到这一点吗?
Can such thing be done when using inline assembly under GCC?
这是我要完成的工作的一个示例:
Here's an example of what I'm trying to accomplish:
__asm__ __volatile__ (
" /* assembly code */ "
" jz external_label; "
);
/* some C code */
external_label:
/* C code coninues... */
但是,编译器抱怨没有定义"external_label".
The compiler, however, complains about "external_label" not being defined.
推荐答案
如果用汇编程序定义标签怎么办?
What if you define the label with the assembler?
asm("external_label:");
更新:此代码似乎有效:
Update: this code seems to work:
#include <stdio.h>
int
main(void)
{
asm("jmp label");
puts("You should not see this.");
asm("label:");
return 0;
}
这篇关于GCC内联汇编:跳转到模块外部的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文