Writing Portable ARM64 Assembly (2023)
- Programming
- Hardware
- Developer Tools
The post is a practical guide to writing ARM64 assembly that can assemble and run on both Apple Silicon and non-Darwin systems. It focuses on the overlap between Mach-O and ELF toolchains, the calling convention details that line up closely enough to share source, and the Apple-specific assembler syntax you need to avoid. The useful claim is narrow but real: if you are writing self-contained routines like math kernels, compression code, or other hot paths that live behind a C interface, you can usually keep one ARM64 source file for macOS and Linux.
If you ship hand-written ARM64, treat portability as a scoped goal: keep compute-heavy routines in a platform-neutral core, then isolate ABI, object format, and syscall glue per target. Do not assume Apple plus Linux covers the whole market, and avoid registers like x18 unless you have checked each platform ABI.
- ariadne.space
- Discuss on HN