开发者

Gnu Assembler (GAS) Optimizations

开发者 https://www.devze.com 2023-02-15 11:17 出处:网络
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

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 ques开发者_JS百科tions 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!


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

0

精彩评论

暂无评论...
验证码 换一张
取 消