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 main cause of the increase in unportable assembly code targeting 64-bit ARM in Apple's computers is the **lack of consideration for other 64-bit ARM devices**.  Developers, aiming to optimize for Apple's ARM platform, are often writing assembly code that relies on Apple-specific features and conventions without realizing that these features are not universally supported on other ARM devices.

Here's a breakdown of the reasons:

* **Apple's unique ecosystem:** Apple has a closed ecosystem with its own operating system (macOS) and toolchain (Xcode). This creates a strong incentive for developers to target Apple-specific features, even if they compromise portability.
* **Focus on performance:**  Performance is crucial for Apple's computers, so developers are motivated to use assembly to gain speed advantages. This can lead to using Apple-specific instructions or assembly syntax, making the code less portable.
* **Lack of awareness:** Many developers may not be aware of the differences between Apple's ARM implementation and other 64-bit ARM platforms, leading them to unknowingly write non-portable code.

The blog post you've quoted is a good example of this problem, highlighting the need for developers to be more conscious of portability when writing assembly code for ARM platforms. By adhering to standard ARM assembly practices and avoiding Apple-specific extensions, developers can ensure their code works across a wider range of ARM devices. 
