Vic*_*rti 10 c x86 assembly gcc
在MSVC下使用内联汇编时,允许通过引用C/C++代码中的标签跳出汇编块之外,如本MSDN文章中所述.
在GCC下使用内联汇编时可以做这样的事吗?
这是我想要完成的一个例子:
__asm__ __volatile__ (
" /* assembly code */ "
" jz external_label; "
);
/* some C code */
external_label:
/* C code coninues... */
Run Code Online (Sandbox Code Playgroud)
但是,编译器抱怨没有定义"external_label".
如果使用汇编程序定义标签怎么办?
asm("external_label:");
Run Code Online (Sandbox Code Playgroud)
更新:此代码似乎有效:
#include <stdio.h>
int
main(void)
{
asm("jmp label");
puts("You should not see this.");
asm("label:");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
从 GCC 4.5 开始,您还可以使用asm goto. 以下示例跳转到 C 标签:
#include <stdio.h>
int main(void) {
asm goto (
"jmp %l[done]" // %l == lowercase L
:
:
:
: done // specify c label(s) here
);
printf("Should not see this\n");
done:
printf("Exiting\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10398 次 |
| 最近记录: |