简体   繁体   English

Gnu汇编(GAS)优化

[英]Gnu Assembler (GAS) Optimizations

Im actually learning assembly and I went with Gas, but the problem is: 我实际上是在学习装配,我和Gas一起去了,但问题是:

1) I only know Intel syntax and I saw in a page Gas with intel syntax is not very good optimized in some cases. 1)我只知道英特尔语法,我在一个页面中看到,在某些情况下,具有intel语法的Gas不是很好。 Is this correct or im wrong? 这是正确还是我错了? Im talking about this web: 我在谈论这个网站:

http://wiki.osdev.org/FASM http://wiki.osdev.org/FASM

2) Then I also saw (i dont remember the page) that the fact gas can assemble in several architectures also slows the assembled program. 2)然后我也看到(我不记得页面)事实气体可以在几个架构中组装也减慢了组装的程序。 Is it right? 这样对吗?

3) Which assembler do you recommend my that produces HIGHLY OPTIMIZED CODE? 3)你推荐哪种汇编程序可以产生高度优化的代码? I saw in other questions that each assembler in some cases can convert to different opcodes. 我在其他问题中看到,在某些情况下,每个汇编程序都可以转换为不同的操作码。 I was between YASM, FASM, GAS and NASM but other recomendations are accepted. 我在YASM,FASM,GAS和NASM之间,但其他推荐被接受。 FASM is know to be very fast... 知道FASM非常快......

Thanks a lot! 非常感谢! Keep that great community! 保持这个伟大的社区!

The primary point of assembly language is that what you write translates directly to individual machine instructions. 汇编语言的主要观点是您所编写的内容直接转换为单个机器指令。 Nearly all optimization is up to you, the programmer. 几乎所有的优化都取决于你,程序员。

An assembler only does a very small number of optimizations that are mostly pretty trivial in any case. 汇编程序只执行非常少量的优化,在任何情况下这些优化都非常简单。 The primary one is that x86 processors have short jumps, near jumps and far jumps. 主要的一点是x86处理器有短跳,近跳和远跳。 Most assemblers can/will optimize a jump to use the smallest form of jump instruction that will get from the source to the destination address. 大多数汇编器可以/将优化跳转以使用从源到目标地址的最小形式的跳转指令。 Even when/if that isn't done automatically, 1) it rarely makes a significant difference in speed (even at the level of counting individual clock cycles), and 2) you can normally add short or near to the instruction to get the smaller size (and the assembler will give you a warning if that won't "reach"). 即使/如果没有自动完成,1)它很少产生显着的速度差异(即使在计算单个时钟周期的水平),2)你通常可以添加shortnear指令以获得更小大小(如果不“达到”,汇编程序会给你一个警告)。

Bottom line: optimization is rarely a much of a reason to choose one assembler over another. 底线:优化很少是选择一个汇编程序而不是另一个汇编程序的理由。 Real reasons are support for the instruction set(s) you care about and the platform(s) you want to target. 真正的原因是支持您关注的指令集和您想要定位的平台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM