Search code examples
rustnasminline-assemblygnu-assembler

Is there a way to use NASM syntax for inline assembly?


I really dislike the GNU Assembler syntax and I some existing code written with NASM syntax that would be quite painful and time consuming to port.

Is it possible to make the global_asm!() macro use NASM as the assembler or possibly make GAS use NASM syntax?


Solution

  • You might be able to change it but it seems as if GAS is the only viable option. In Directives Support: 'Inline assembly supports a subset of the directives supported by both GNU AS and LLVM's internal assembler, given as follows. The result of using other directives is assembler-specific (and may cause an error, or may be accepted as-is).' Additionally,the documentation states "Currently, all supported targets follow the assembly code syntax used by LLVM's internal assembler which usually corresponds to that of the GNU assembler (GAS). On x86, the .intel_syntax noprefix mode of GAS is used by default.'

    This might be helpful as well https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md