6 ms·
It's a good guide. There's a lot of details in exchanging data between your C function and ASM (beyond simply assembly). But AT&T assembly syntax is not nice.
by raverbashing 7y ago
It's a good guide. There's a lot of details in exchanging data between your C function and ASM (beyond simply assembly).
But AT&T assembly syntax is not nice. Not nice at all.
- e12e 7y agoIs it advisable to actually try and use .intel_syntax and -masm=Intel?
- bonzini 7y agoIf you have enough inline assembly that it makes a difference, then AT&T syntax is probably not your biggest problem!
- raverbashing 7y agoTrue! I'm very glad Intrinsics were invented
- DSMan195276 7y agoHaving used gcc inline assembly a decent amount, I'd personally say it's not worth it. Almost every example and existing code out there is AT&T, so you're creating an extra step for yourself in converting to intel, and IMO AT&T syntax isn't that bad - it's not great by any means, but having started with intel syntax I didn't find AT&T that hard to pick up (Besides the source/dest thing, which is really annoying). I think the big thing to note is that your inline assembly should really be as short as possible - larger sections are going to have more and more inputs/outputs/constraints, and those will prevent gcc from doing lots of optimizations with it since it doesn't understand and can't modify the assembly (I could go into more details on this if you'd like, if you're not already aware of this). For most use-cases, your inline assembly should just be exposing things you can't do in C (Like exotic or CPU-specific instructions) for use in your C code. So at that point, most of your inline assembly just becomes one or two instructions long, and the syntax doesn't really matter as much. For larger blocks of assembly, you should just compile it separately (At which point you could use intel syntax if you like).
- mhd 7y agoI knew some Amiga programmers who liked it because the different source/target order.
- pjmlp 7y agoBoth AT&T syntax and lack of assembly blocks, it is like UNIX devs love doing stuff the hard way.
- panpanna 7y agoIt looks much more sane on ARM and MIPS. On x86 most people seem to use NASM for non-inline assembler.
- pjmlp 7y agoYep, as we used TASM and MASM before it. That is another thing that you remind me of, the macro assembler capabilities of non-UNIX assemblers.
- panpanna 7y agoActually, GAS can do full C-preprocessor via GCC. Just call your file file.S (big S). You can't really get a better macro system than that.