News for hackers. Stuff that matters.
Re:(Debugging Story) Inline Assembly Dangers by cesarb on Monday June 10, 2024 @08:12AM (#40632730)
> [...] are a bit more knowledgeable of what those Assembly instructions are actually doing. Not only that, they are able to provide proper error messages when the opcodes are badly used.

That's only possible if the compiler knows all assembly instructions being used. But the whole point of GCC-style inline assembly is to be able to use assembly instructions the compiler doesn't know about (for instance, because they're new instructions which didn't exist when the compiler was released), with the same performance as the ones the compiler does know about. In many cases, even the assembler doesn't know about the new instruction, and you have to specify it using .byte directives or similar (though the Unix compiler model, with proper separation between the compiler and the assembler, also allows you to use a newer assembler without having to change your compiler).

Re:(Debugging Story) Inline Assembly Dangers by pjmlp on Monday June 10, 2024 @09:41AM (#40633600)
Again, this kind of arguments gets tiring, compilers get upgrades.
Re:(Debugging Story) Inline Assembly Dangers by leni536 on Monday June 10, 2024 @10:31AM (#40634062)
And GCC/clang do get intrinsics that are nicer to use than inline asm, often with more optimization available to them as well.

If the compiler does know about a specific instruction, then it's better to just provide the intrinsic than try to infer it from some inline asm string.

Re:(Debugging Story) Inline Assembly Dangers by AshamedCaptain on Monday June 10, 2024 @11:03AM (#40634398)
One of the benefits of gcc's powerful inline asm support is that it allows you to write new intrinsics. This is almost impossible in most other compilers, as they will do crazy things such as flushing out all registers before each asm block. Very useful for low level work.
Re:(Debugging Story) Inline Assembly Dangers by leni536 on Monday June 10, 2024 @11:45AM (#40634808)
> it allows you to write new intrinsics

I admit that it gets very close, however I think compiler provided intrinsics can be and are optimized more than ones that are implemented with inline asm, as the compiler knows about the semantics of the instruction for such an intrinsic, and not much about an inline asm one, apart from inputs/outputs/clobbers.

Having said that I agree that inline asm is very useful for instructions that the compiler does not know about.

Re:(Debugging Story) Inline Assembly Dangers by secondcoming on Monday June 10, 2024 @11:05AM (#40634427)
That's great if you're not locked down to a particular compiler version