Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disassembly should use Intel syntax by default #84

Open
lhmouse opened this issue Nov 24, 2023 · 1 comment
Open

Disassembly should use Intel syntax by default #84

lhmouse opened this issue Nov 24, 2023 · 1 comment

Comments

@lhmouse
Copy link

lhmouse commented Nov 24, 2023

Indeed there are some issues with the Intel syntax e.g. one may want to use SP as the name of a function or static variable which would confuse the assembler, but for code that is to be read by humans, there is really no reason to prefer the awkward AT&T syntax.

Other than official Intel and AMD documentation,

  1. The great work by Ed Jorgensen uses Intel syntax with YASM: http://www.egr.unlv.edu/~ed/assembly64.pdf
    We also note this course is for Ubuntu but they don't use the GNU assembler.
  2. The μop database uses Intel syntax: https://uops.info/table_overview.html
  3. The Compiler Explorer uses Intel syntax by default: https://gcc.godbolt.org/
  4. The FreeBSD handbook uses Intel syntax with NASM: https://docs.freebsd.org/en/books/developers-handbook/x86/
    This is another non-Windows platform. All assemblers that targe x86 and x86-64, except the GNU assembler, use Intel syntax: nasm, yasm, etc.
  5. The x64dbg debugger uses Intel syntax: https://x64dbg.com/
@lhmouse
Copy link
Author

lhmouse commented Nov 27, 2023

Also there should be an option to set the input syntax i.e. to pass -masm=intel to GCC, so inline assembly can be in Intel syntax. Hence

    __asm__ volatile (
      "lock cmpxchg %0, %2"
      : "+m"(value), "+a"(cmp) : "c"(swap)
      //  0            1          2
    );

will be accepted as lock cmpxchg qword ptr [rsp + 16], rcx instead of some GNU nonsense such as

Error: operand size mismatch for `cmpxchg'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant