What's the cause of the increase in unportable assembly code which targets the 64-bit ARM ISA in Apple’s ARM-based computers?

Writing portable ARM64 assembly
Apr 13, 2023
An unfortunate side effect of the rising popularity of Apple’s ARM-based computers is an increase in unportable assembly code which targets the 64-bit ARM ISA. This is because developers are writing these bits of assembly code to speed up their programs when run on Apple’s ARM-based computers, without considering the other 64-bit ARM devices out there, such as SBCs and servers running Linux or BSD.

The good news is that it is very easy to write assembly which targets Apple’s computers as well as the other 64-bit ARM devices running operating systems other than Darwin. It just requires being aware of a few differences between the Mach-O and ELF ABIs, as well as knowing what Apple-specific syntax extensions to avoid. By following the guidance in this blog, you will be able to write assembly code which is portable between Apple’s toolchain, the official ARM assembly toolchain, and the GNU toolchain.
The article you've provided explains the cause of the increase in unportable assembly code targeting the 64-bit ARM ISA in Apple's ARM-based computers:

**The cause is the focus on performance optimization for Apple's specific ARM architecture.**

* **Apple's Popularity:** The rise of Apple's ARM-based computers (Macs) has led to developers prioritizing performance gains on these devices. 
* **Assembly Code for Optimization:** Assembly code offers the potential for significant performance improvements, making it attractive for developers seeking to optimize their software for Apple's ARM architecture.
* **Lack of Cross-Platform Consideration:** Developers often focus on Apple's specific ARM architecture and its associated tools (Mach-O ABI), neglecting the need for portability to other 64-bit ARM devices using different operating systems and toolchains (like ELF ABI). This leads to the creation of assembly code that is specific to Apple's environment and thus, not portable.

**The article then goes on to highlight that writing portable ARM64 assembly code is possible.**  It suggests that developers can write portable code by:

* **Understanding ABI differences:**  Being aware of the differences between the Mach-O and ELF ABIs, which define how code is structured and linked.
* **Avoiding Apple-specific syntax:**  Avoiding Apple-specific extensions to the ARM assembly language.

By following these guidelines, developers can create assembly code that works across different ARM platforms, ensuring their code's portability and future-proofing it for use on a wider range of devices. 
