Gnu 汇编器 (GAS) 优化

发布于 2024-10-20 16:50:39 字数 425 浏览 4 评论 0原文

我实际上正在学习汇编,并且使用了 Gas,但问题是:

1)我只知道 Intel 语法,并且我在页面中看到具有 Intel 语法的 Gas 在某些情况下没有得到很好的优化。这是正确的还是错误的?我正在谈论这个网站:

http://wiki.osdev.org/FASM

2)然后我也看到(我不记得页面了)事实是,gas 可以在多种架构中组装,这也会减慢组装程序的速度。对吗?

3) 您推荐我使用哪种汇编器来生成高度优化的代码?我在其他问题中看到,在某些情况下每个汇编器都可以转换为不同的操作码。我介于 YASM、FASM、GAS 和 NASM 之间,但其他建议也被接受。众所周知,FASM 速度非常快...

非常感谢!保持这个伟大的社区!

Im actually learning assembly and I went with Gas, but the problem is:

1) I only know Intel syntax and I saw in a page Gas with intel syntax is not very good optimized in some cases. Is this correct or im wrong? Im talking about this web:

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. Is it right?

3) Which assembler do you recommend my that produces HIGHLY OPTIMIZED CODE? 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. FASM is know to be very fast...

Thanks a lot! Keep that great community!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柏林苍穹下 2024-10-27 16:50:39

汇编语言的要点是您编写的内容可以直接转换为单独的机器指令。几乎所有优化都取决于程序员。

汇编器只进行极少数的优化,这些优化在任何情况下都是相当微不足道的。第一个是 x86 处理器有短跳转、近跳转和远跳转。大多数汇编器可以/将优化跳转以使用从源地址到目标地址的最小形式的跳转指令。即使这没有自动完成,1)它很少会对速度产生显着差异(即使在计算单个时钟周期的水平上),2)您通常可以添加 short 或 < code>靠近指令以获得更小的尺寸(如果不能“达到”,汇编器会给你一个警告)。

底线:优化很少成为选择一种汇编器而不是另一种汇编器的理由。真正的原因是支持您关心的指令集和您想要的目标平台。

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. 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").

Bottom line: optimization is rarely 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文