NASM(Intel)与AT& T语法:有哪些优势? [英] NASM (Intel) versus AT&T Syntax: what are the advantages?

查看:119
本文介绍了NASM(Intel)与AT& T语法:有哪些优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读英特尔处理器文档,并同时编写一些基本的汇编代码.我的服务器上同时有nasmas(GAS),并且我了解了两个汇编程序的基本区别.

从长远来看:

  • 重点关注哪种语法是更好的主意?
  • 这些语法的优缺点是什么?
  • 哪个被更广泛地使用和理解?

我也非常感谢您可以与我分享任何偏好.

解决方案

  • 重点关注哪种语法是更好的主意?

取决于您的项目.并非每个编译器都允许两种语法.如果您需要在其他平台上进行汇编的代码,即使我有多年的工作经验,但我个人还是更喜欢Intel,但Intel可能会更好.但这只是很小的差异,对我而言并不重要.

  • 这些语法的优缺点是什么?

在AT& T语法中,%稍微多一些,如果需要使用宏,则更多. OTOH我更喜欢 source,destination 的顺序,但是那是个人喜好,其他人可能更喜欢它,因为它类似于C中的赋值运算符的书写顺序(甚至更多).

我的INTEL语法很像DWORD PTR这样的ob语,在AT& T中,一个小的附加l就足够了.在许多情况下,助记符的确切拼写有所不同,我发现AT& T更合乎逻辑,而Intel的方式当然是标准.英特尔中的寻址模式更具可读性.

  • 哪个被更广泛地使用和理解?

我相信AT& T被更多地使用,因为Linux在嵌入式平台上无处不在,在其他软件项目中,汇编器的使用率更高.有更多的汇编器了解Intel的语法,这是事实,但我相信gcc/gas在汇编器重要/有用的领域中使用更多.

I'm going through the Intel processor documentation and writing some basic assembly code at the same time. I have both nasm and as (GAS) on my server and I understand the basic differences of both assemblers.

In the long run:

  • Focusing on which of these syntax is a better idea?
  • What are the advantages and disadvantages of these syntax?
  • Which one is more widely used and understood?

I would also appreciate any preferences you could share with me.

解决方案

  • Focusing on which of these syntax is a better idea?

Depends on your projects. Not every compiler does allow both kinds of syntax. If you need to have to code assembled on other platforms Intel is probably better, even after some years experience with both I personally like Intel more, but it`s a small difference, and it doesn't really matter to me.

  • What are the advantages and disadvantages of these syntax?

In the AT&T syntax there are slightly to much %, even more if you need to use macros. OTOH I prefer the source, destination ordering, but thats personal taste, others may prefer it the other way around because it resembles the writing order of an assignment operator in say C (and many more).

I INTEL syntax the are obscenities like DWORD PTR, where in AT&T a small appended l is sufficient. The exact spelling of the mnemonics differs in many cases, I find the AT&T more logical while of course Intels way is the standard. The addressing modes in Intel are somewhat more readable.

  • Which one is more widely used and understood?

I believe AT&T is more used, because of the ubiquitousness of linux on embedded platforms, where assembler is much more often used that in other software projects. There are more assemblers which understand Intels syntax, that much is true, but I believe gcc/gas is more used in a field where assembler matters/is useful .

这篇关于NASM(Intel)与AT& T语法:有哪些优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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