如何在GCC C ++中编写多行内联汇编代码? [英] How to write multiline inline assembly code in GCC C++?
本文介绍了如何在GCC C ++中编写多行内联汇编代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这看起来不太友好:
__asm("command 1"
"command 2"
"command 3");
我真的必须在每行两边加上双引号吗?
Do I really have to put a doublequote around every line?
而且...由于多行字符串文字在GCC中不起作用,因此我也无法作弊.
Also... since multiline string literals do not work in GCC, I could not cheat with that either.
推荐答案
我总是在Internet上找到一些示例,该示例是该人手动插入制表符和换行符而不是\ t和\ n的示例,但是它不适用于我.不太确定您的示例是否可以编译..但这就是我的方法:
I always find some examples on Internet that the guy manually insert a tab and new-line instead of \t and \n, however it doesn't work for me. Not very sure if your example even compile.. but this is how I do:
非常丑陋的方式:
asm("xor %eax,%eax");
asm("mov $0x7c802446, %ebx");
asm("mov $500, %ax");
asm("push %eax");
asm("call *%ebx");
或者这个不太丑的人:
asm("xor %eax,%eax \t\n\
mov $0x7c802446, %ebx \t\n\
mov $1000, %ax \t\n\
push %eax \t\n\
call *%ebx \t\n\
");
这篇关于如何在GCC C ++中编写多行内联汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文