Rules to Avoid Common Extended Inline Assembly Mistakes
2024-12-21
This article isn't an inline assembly tutorial, but rather a summary of six rules to avoid common mistakes. The author emphasizes that inline assembly is treacherous and should be avoided whenever possible, as modern compilers offer intrinsics and built-ins for most use cases. If unavoidable, the rules are: use the `volatile` qualifier; use a `memory` clobber if accessing memory; never modify input constraints; never call functions from inline assembly; don't define absolute assembly labels; and use the assembler's local label feature to avoid label conflicts. The article concludes by encouraging readers to practice applying these rules by reviewing online tutorials and even LLM-generated code.