我可以用x86汇编的Intel语法与海湾合作委员会? [英] Can I use Intel syntax of x86 assembly with GCC?

查看:254
本文介绍了我可以用x86汇编的Intel语法与海湾合作委员会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个小低水平程序。对于它的某些部分,我将需要使用汇编语言,但code的其余部分将在C / C ++编写。

I want to write a small low level program. For some parts of it I will need to use assembly language, but the rest of the code will be written on C/C++.

所以,如果我将使用GCC汇编code混合C / C ++,我是否需要使用AT& T公司的语法还是可以的
我使用英特尔的语法?或者,你如何以其它方式混合使用C / C ++和汇编(Intel语法)?

So, if I will use GCC to mix C/C++ with assembly code, do I need to use AT&T syntax or can I use Intel syntax? Or how do you mix C/C++ and asm (intel syntax) in some other way?

我意识到也许我没有选择,必须使用AT& T公司的语法,但我想肯定。

I realize that maybe I don't have a choice and must use AT&T syntax, but I want to be sure..

如果有原来是没有选择,在那里我可以找到有关AT&放满/正式文件; T语法

And if there turns out to be no choice, where I can find full/official documentation about the AT&T syntax?

谢谢!

推荐答案

如果您使用的是单独的汇编文件,燃气具有一个指令,支持Intel语法:

If you are using separate assembly files, gas has a directive to support Intel syntax:

.intel_syntax noprefix

它采用了英特尔的语法和寄存器名称之前不需要%preFIX。

which uses Intel syntax and doesn't need the % prefix before register names.

如果您使用的是内联汇编,你可以用 -masm =英特尔编译

If you are using inline assembly, you can compile with -masm=intel

使用 .intel_syntax没有preFIX 的内联汇编开始,然后再切换回用 .att_syntax 可以工作,但将打破如果您使用任何 M 的约束。内存引用仍将在AT&放大器生成; T语法

Using .intel_syntax noprefix at the start of inline asm, and switching back with .att_syntax can work, but will break if you use any m constraints. The memory reference will still be generated in AT&T syntax.

这篇关于我可以用x86汇编的Intel语法与海湾合作委员会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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