gas vs. nasm: which assembler produces the best code?

前端 未结 6 1432
挽巷
挽巷 2021-02-14 02:46

Both tools translate assembly instructions directly into machine code, but is it possible to determine which one produces the fastest and cleanest code?

6条回答
  •  庸人自扰
    2021-02-14 03:22

    I don't know about these two specific tools, but there are some instructions that can be encoded differently:

    • ADD AX,1 is either 05 01 or 81 c0 01 or fe c0
    • INT 3 is either cc or cd 03
    • New AVX instructions that extend two-byte SSE instructions will either have a 2-byte or 3-byte prefix. All 2-byte prefixes can be encoded as 3-byte prefixes as well.

    These are just a few examples off the top of my head of how assemblers can encode the same instruction differently, so the question does in fact make sense.

提交回复
热议问题