-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
integrated assembly and intel/NASM syntax for x86 assembly #2081
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
Comments
Previously, global assembly was parsed expecting it to have the template syntax. However global assembly has no inputs, outputs, or clobbers, and thus does not have template syntax. This is now fixed. This commit also adds a compile error for using volatile on global assembly, since it is meaningless. closes #1515
From 15c316b#r32851500 : We should specify an assembly syntax annotation/choice/argument to allow the choice of assembly syntax layer on. return asm volatile (builtin.asmSyntax.att, "syscall"
: [ret] "={rax}" (-> usize)
: [number] "{rax}" (number),
[arg1] "{rdi}" (arg1)
: "rcx", "r11"
); |
I don't think Zig will acknowledge multiple assembly syntaxes. But you can do this in your assembly: .intel_syntax noprefix Again, I recommend against this due to the reasons mentioned above. |
New instructions are being added all the time to architectures, which makes an assembler a very high maintenance piece of software. This maintenance burden isn't as big of a deal when the hardware developers add support to llvm and gcc before they release their hardware, but it is unrealistic to expect them to add support to other tool-chains. Wouldn't it be easier just to fix llvm's Intel syntax? |
We'll need our own assemblers anyway, if we want a libc-less system interface with LLVM-less builds; so, making our own improvements is effectively zero-cost. I say it would be wise not to stray too far from GCC/LLVM, for compatibility, but we can make a few small changes:
We may also consider some niceties:
|
^^^ |
Extracted from #215 (comment).
Currently Zig relies on LLVM for assembly parsing on all targets.
It's a big project if Zig were to take on knowledge of the assembly format of every supported target, but if we were to do that, it would bring some benefits:
Intel/NASM syntax for x86 which is generally preferable to AT&T syntax which we are currently stuck with due to LLVM's Intel syntax support being untested and buggy.
Ability for tighter integration with Zig code that could do things such as automatically determining clobbers.
Maybe it's not so bad to reduce dependency on LLVM. This would bring us closer to a fully self hosted toolchain and make it possible to experiment with bypassing LLVM in debug mode for faster builds.
So I think this proposal is at least worth considering. There will have to be a decision before releasing 1.0.0.
The text was updated successfully, but these errors were encountered: